我有一个情况,我必须总和和最大数量处理多个条目每天。我在cloudera配置单元中有一个输入表:
----------------------------
date1 | date2 | qty
----------------------------
20180101 | 20180101 | 50
----------------------------
20180101 | 20180101 | 15
----------------------------
20180101 | 20180102 | 1
----------------------------
20180101 | 20180103 | 3
----------------------------
20180101 | 20180104 | 2
----------------------------
Final answer I need is :
----------------------------
date1 | qty
----------------------------
20180101 | 56
----------------------------
Logic: For date1 cal 20180101
= max(20180101 i.e date2) + sum ( all other date2)
= max(50,15) + sum(1,3,2)
= 56
**Will the lag / lead work here, can anyone help me with a hint of the
solution?
Thanks in advance.**
1条答案
按热度按时间yyyllmsg1#
您可以尝试下面的查询和检查