SELECT
C. cdrs_id AS cdrs_id,
C. cdrs_cc_card AS cdrs_cc_card,
C. cdrs_starttime AS cdrs_starttime,
C. cdrs_sessiontime AS cdrs_sessiontime,
S. login_source AS login_source
FROM
[Dataset.Statistics_Application] AS S
JOIN EACH [Dataset.User_Info] AS U ON S. user_id = U. id
JOIN EACH [Dataset.CDRSTrafficDB] AS C ON U. vcard = C. cdrs_cc_card AND C. cdrs_starttime BETWEEN S. start_date AND S. end_date
GROUP BY
cdrs_id,
cdrs_cc_card,
cdrs_starttime,
cdrs_sessiontime,
login_source
有一种方法可以写入每个具有=
条件和between
条件的联接。
错误:ON子句必须与AND = =每个表中一个字段名称的比较,所有字段名称都以表名称为前缀。
答案 0 :(得分:0)
Standard SQL没有此限制。您可以使用这种形式的查询;请注意,表名转义和删除EACH
的区别:
#standardSQL
SELECT
C. cdrs_id AS cdrs_id,
C. cdrs_cc_card AS cdrs_cc_card,
C. cdrs_starttime AS cdrs_starttime,
C. cdrs_sessiontime AS cdrs_sessiontime,
S. login_source AS login_source
FROM
`Dataset.Statistics_Application` AS S
JOIN `Dataset.User_Info` AS U ON S. user_id = U. id
JOIN `Dataset.CDRSTrafficDB` AS C ON U. vcard = C. cdrs_cc_card AND C. cdrs_starttime BETWEEN S. start_date AND S. end_date
GROUP BY
cdrs_id,
cdrs_cc_card,
cdrs_starttime,
cdrs_sessiontime,
login_source