我有两个表,我的外部选择聚合所有那些存在于我放在where子句中的另一个表中的id。两个表都是使用通配符函数生成的。以下是查询 -
SELECT count(id), timestamp FROM (TABLE_QUERY(dataset1, 'expr'))
WHERE id IN (SELECT id FROM (TABLE_QUERY(dataset1, 'expr'))
WHERE timestamp < 1414670361836) ) group by timestamp
我收到以下错误 -
查询失败错误:(L1:56):JOIN(包括半连接)和UNION ALL (逗号)不能组合在一个SELECT语句中。要么搬家 UNION ALL为内部查询或JOIN为外部查询。
有人能指出我是什么问题,我该如何解决?
答案 0 :(得分:7)
使用处理公共数据的查询重新措辞。
这不起作用:
SELECT COUNT(actor), created_at
FROM (TABLE_QUERY([publicdata:samples], "table_id CONTAINS 'github'"))
WHERE actor IN (
SELECT actor
FROM (TABLE_QUERY([publicdata:samples], "table_id CONTAINS 'github'"))
WHERE created_at > '')
GROUP BY created_at
Error: (L2:1): JOIN (including semi-join) and UNION ALL (comma) may not be combined in a single SELECT statement. Either move the UNION ALL to an inner query or the JOIN to an outer query.
这样做:
SELECT COUNT(actor), created_at
FROM (
SELECT actor, created_at
FROM (TABLE_QUERY([publicdata:samples], "table_id CONTAINS 'github'"))
)
WHERE actor IN (
SELECT actor
FROM (TABLE_QUERY([publicdata:samples], "table_id CONTAINS 'github'"))
WHERE created_at > ''
LIMIT 100)
GROUP BY created_at
我刚刚移动了
SELECT actor, created_at
FROM (TABLE_QUERY([publicdata:samples], "table_id CONTAINS 'github'"))
到内部查询。