例如,我有一个表
订单{o\u orderkey,o\u custkey,o\u orderstatus,o\u totalprice,o\u orderdate,o\u orderpriority,o\u clerk…诸如此类…}
我试过了
SELECT o_orderkey, o_orderdate, sum(o_totalprice)
FROM orders
GROUP BY CUBE (o_orderkey, o_orderdate)
ORDER BY o_orderkey, o_orderdate;
但这给了我一个错误:
错误:编译语句时出错:失败:parseexception行4:5无法识别“cube”(表达式规范中的“o\u orderkey”(状态=42000,代码=40000)附近的输入
所以我找到了问题的答案,现在我有了第二张table
行项目{l\u orderkey,l\u suppkey和…等等…}
第一个表通过orderkey字段链接到此lineitem表,
所以我想找出这两个职员订购的零件总数(o\ U职员)
o#clerk='clerk#000000522'或o#clerk='clerk#000000154'
orderdate(o\u orderdate),每个suppkey(l\u suppkey)。
这是我的工作,但我不确定是否正确:
SELECT o_clerk, o_orderdate, l.l_suppkey, sum(l.l_quantity) as TotalParts
FROM orders as o, lineitem as l
WHERE o.o_orderkey = l.l_orderkey
AND o.o_clerk='Clerk#000000522' OR o.o_clerk='Clerk#000000154'
GROUP BY o_clerk, o_orderdate, l.l_suppkey WITH CUBE
ORDER BY o_orderdate, l.l_suppkey;
1条答案
按热度按时间sshcrbum1#
在hive中,您可以这样说: