on-internet
← Community

How to filter by a column generated in the same query?

Stack Overflow ·

The below is a very simple query where my_data consists only of 1 row, and it's there only to help me explain my issue better. WITH my_data AS( SELECT TIMESTAMP("2020-02-11 13:15:00 UTC") AS my_timestamp ,50 AS my_customers) SELECT DATE(my_timestamp) AS my_date ,my_customers FROM my_data WHERE my_date = "2020-02-11" This won't run in Google Big Query's standard SQL, although I recall running something similar in the past. The reason it won't run is that it doesn't know what my_date is, and my guess is because it's getting created in the same query. My question is: Can I filter by a new generat

Comments

Sign in or sign up to comment and upvote.

No comments yet.