Hello, I have a question that I can't solve,
How do you do in bigquery to store the value of a subquery and use it in another field?
For example let's say that I have a subquery that returns me the number of passengers of a route. Then I want to do a compariso with that value for another field. The following code is correct for MySQL, how can I do the same procedure for BigQuery?
(SELECT @aux := COUNT(*) FROM consumptions WHERE route = "X1"),
IF(@aux = 0 ,@aux:= another_field, @auxpax) AS total_consumptions
I have tried several things such as using DECLARE/SET, ...
Help would be really appreciated 🙂