我有以下查询:
WITH modalities as (
SELECT DISTINCT
col4 as modalities
FROM `myproject.table1`
SELECT
CONCAT("""
SELECT
col1,col2, col3
""",
STRING_AGG( if_clauses , """,
"""),
"""
FROM `myproject.table1`
GROUP BY col1,col2, col3
ORDER BY col1,col2
""") as query
FROM
(
SELECT
CONCAT ("SUM(IF (col4 = '",tcc, "',1,0)) as ", col4) as if_clauses
FROM contact_type )
'''
基本上,它的作用是生成对一个热编码col4的查询:对于每种形式,我们都会生成一个新列。该查询返回一行带有一个字符串单元格的一行。
如何解释此查询?我正在搜索
之类的东西With query as (...)
SELECT * FROM INTERPRET(QUERY)