Home > database >  SQL BigQuery - Use WITH view in 'IN' clause
SQL BigQuery - Use WITH view in 'IN' clause

Time:10-27

Does BigQuery support the usage of WITH views in the 'IN' clause?

WITH validyears as (SELECT Year FROM movies WHERE Year > 2005)

SELECT * 
FROM movies 
WHERE Year IN validyears

I get "Unrecognized name" error.

CodePudding user response:

Try this

WITH validyears as (SELECT Year FROM movies WHERE Year > 2005)

SELECT * 
FROM movies 
WHERE Year IN (Select year from validyears)
  • Related