我试图弄清楚如何发出一个包含多个查询的请求,以便生成一个包含所有查询结果的视图。
举个例子:
WITH Query_1 AS
(
SELECT
dimension1,
dimension2,
dimension3,
dimension4,
dimension5,
CASE WHEN STARTS_WITH (dimension1, "N_") THEN '1' ELSE '0' END AS qadimension1,
CASE WHEN dimension2 IS NOT NULL THEN dimension2 ELSE '0' END AS qadimension2,
CASE WHEN dimension3 IS NOT NULL THEN dimension3 ELSE '0' END AS qadimension3,
CASE WHEN dimension4 IS NOT NULL THEN dimension4 ELSE '0' END AS qadimension4,
FROM `XXXXX.XXXXX.first_view`
WHERE dimension5='2021' AND dimension1 IS NOT NULL),
Query_2 AS (
SELECT
dimension1,
qadimension1,
dimension6,
CASE WHEN qadimension1 = dimension6 THEN '1' ELSE '0' END AS QA_check1,
FROM `XXXXX.XXXXX.first_view` , `XXXXX.XXXXX.second_view`
WHERE qadimension1 != '0'),
Query_3 AS (
SELECT
dimension1,
qadimension2,
dimension7,
CASE WHEN qadimension2 = dimension7 THEN '1' ELSE '0' END AS QA_check2,
FROM `XXXXX.XXXXX.first_view` , `XXXXX.XXXXX.third_view`
WHERE qadimension2 != '0')
SELECT
dimension1,
dimension2,
dimension3,
dimension4,
dimension5,
dimension6,
dimension7,
qadimension1,
qadimension2,
qadimension3,
qadimension4,
QA_check1,
QA_check2,
FROM
Query_1,
Query_2,
Query_3
WHERE FULL JOIN dimension1;
仍有错误:语法错误:在[242:7]处出现意外的关键字full
非常感谢你的帮助
1条答案
按热度按时间ejk8hzay1#
下面是bigquery标准sql
尝试下面-注意所有CTE没有变化,所以下面只是最后的select语句