Home:ALL Converter>Calculated column based on another calculated field BigQuery

Calculated column based on another calculated field BigQuery

Ask Time:2022-05-24T23:40:01         Author:jrrodasm

Json Formatter

Hello I'm trying to use an already calculated value in a select to calculate another value, for example:

SELECT 1+1 AS two, ***two* + 2** AS four FROM table

is this possible in BigQuery? I'm sure it's on SAS with the keyword CALCULATED as follows:

SELECT 1+1 as two, ***CALCULATED two* + 2** AS four FROM table

Thank you,

Author:jrrodasm,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72365740/calculated-column-based-on-another-calculated-field-bigquery
Mikhail Berlyant :

Below is example of how I personally approach such scenario (quite frequently btw)\nSELECT two, two + 2 AS four \nFROM table, UNNEST([STRUCT(1+1 as two)]) \n",
2022-05-24T22:54:06
yy