我试图运行下一个查询
select sum(balance) over (partition by client order by card desc, date_tr desc)
from table_1
在结果中,我收到下一条错误消息:
FAILED: SemanticException Range based Window Frame can have only 1 Sort key
是真的,我不能在order by
句子中使用2个排序键吗?或者有一种方法可以使用2个排序键?
答案 0 :(得分:3)
您的代码应该可以使用。 language manual有一个非常相似的例子。
也就是说,显式的window子句可能会绕过该错误:
select sum(balance) over (partition by client
order by card desc, date_tr desc
rows between unbounded preceding and current row
)
from table_1
答案 1 :(得分:1)
请查看以下答案以了解GROUP和PARTITION BY之间的区别,尽管它取决于您的实际需求,但它应该可以工作:Difference GROUP BY and PARTITION BY