with max_item_id as (select item_id ( select item_id,sum(amt) as sum_amt,rom_number() over(order by sum(amt) desc ) rn from table_a where to_date(dt,'yyyymmdd')>=to_date('20180701','yyyymmdd') and to_date(dt,'yyyymmdd')<=to_date('20180931','yyyymmdd') and a.seller_id='123' group by item_id )t where t.rn=1 ) select item_id,buyer_id from ( select a.item_id,a.buyer_id,sum(a.amt) sum_buyer_id,rom_number() over(order by sum(a.amt) desc ) rn from table_a a join max_item_id b on a.item_id=b.item_id where to_date(dt,'yyyymmdd')>=to_date('20180701','yyyymmdd') and to_date(dt,'yyyymmdd')<=to_date('20180931','yyyymmdd') and a.seller_id='123' group by a.item_id,a.buyer_id ) t where t.rn=1 ;
点赞 1

相关推荐

StephenZ_:我9月份找的第一段实习也是遇到这种骗子公司了,问他后端有多少人和我说7个正职,进去一看只有一个后端剩下的都是产品前端算法(没错甚至还有算法)。还是某制造业中大厂,我离职的时候还阴阳怪气我
点赞 评论 收藏
分享
12-13 20:26
浙江大学 Java
淬月星辉:把浙大的校名加大加粗,把校徽再贴出来,就OK了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务