在GoogleBigQuerry中的示例数据集上运行JOIN

时间:2014-01-02 10:51:23

标签: syntax google-bigquery

我正在评估Google Bigquerry平台与SQL服务器的比较以分析我的网站数据。我试图对它们提供的样本数据集运行以下查询,但我不确定它为什么会出错

(SELECT corpus, sum(word_count) AS wordcount 
FROM publicdata:samples.shakespeare GROUP BY corpus) as set1
join
(SELECT corpus as corpus2, sum(word_count) AS wordcount2
FROM publicdata:samples.shakespeare where corpus = 'hamlet' GROUP BY corpus ) as set2
on set1.wordcount = set2.wordcount2;

(错误:遇到“”AS“”as“”在第2行,第78栏。期待:EOF)

有没有人有想法?

提前致谢 史尔皮

1 个答案:

答案 0 :(得分:2)

你错过了一个选择短语......

select * from 
(SELECT corpus, sum(word_count) AS wordcount 
 FROM publicdata:samples.shakespeare 
 GROUP BY corpus) as set1 
join 
(SELECT corpus as corpus2, sum(word_count) AS wordcount2 
 FROM publicdata:samples.shakespeare where corpus = 'hamlet' 
 GROUP BY corpus ) as set2 
 on set1.wordcount = set2.wordcount2;