有人可以帮我理解这个查询的错误吗?
BigQuery显示错误:
错误:无法识别的名称:[...]
的case1
SELECT
col1,
CASE
WHEN col2 IN ('text1') THEN 1
ELSE 0
END as case1
CASE
WHEN col2 IN ('text2') THEN 1
ELSE 0
END as case2
FROM `dataset.tablename`
WHERE case1 = 1 OR case2 = 1
答案 0 :(得分:1)
SELECT
col1,
CASE
WHEN col2 IN ('text') THEN 1
ELSE 0
END as case1
FROM `dataset.tablename`
WHERE CASE
WHEN col2 IN ('text') THEN 1
ELSE 0
END = 1
您无法在同一语句中查询别名