我必须根据字段DT进行分组并计算其出现次数。表存储在Google Big Query中。
SELECT c.Id1 AS HId, d.Id1 as PId,e.Type as DT
FROM
[RawGps32.T20160601] c
LEFT JOIN
[VN_20160601] d
ON c.Id1 = d.Id1
INNER JOIN [SF.DT] e
ON d.Id1 = e.Id1
GROUP BY HId, PId,DT
HAVING HId in (3928,3602,1285,4663,96546)
当前结果:
HId PId DT
3928 11 G1
3602 12 G3
1285 12 G1
4663 14 G4
96546 15 G1
预期结果
DT count
G1 3
G3 1
G4 1
任何帮助都将不胜感激。
答案 0 :(得分:0)
最有可能
SELECT e.Type as DT, count(*) as count
FROM
[RawGps32.T20160601] c
LEFT JOIN
[VN_20160601] d
ON c.Id1 = d.Id1
INNER JOIN [SF.DT] e
ON d.Id1 = e.Id1
WHERE c.Id1 in (3928,3602,1285,4663,96546)
GROUP BY e.Type
ORDER BY e.Type
另请注意,由于LEFT JOIN [VN_20160601] d
遵循INNER
禁止INNER JOIN [SF.DT] e ON d.Id1 = e.Id1
处的NULL,因此d.id1
实际上是LEFT JOIN
。可能两者都应该是 .hidden-xs {
display: none !important;
}
。