with tmp as( select c.item_id from (select b.item_id, b.sum_amt, rank()over(order by b.sum_amt desc) rnk from (select item_id, sum(amt) sum_amt from (select buyer_id, item_id, amt from A  where month(dt) in (7,8,9) and seller_id = '123' )a group by item_id )b )c where c.rnk = 1)      select buyer_id, item_id from A where item id = (select item_id from tmp) group by buyer_id, item_id order by SUM(amt) desc limit 1
点赞 评论

相关推荐

缒梦&独舞:这家公司是这样的,去年给我实习offer了,不过也是面着玩儿的,他周六还要去做公益志愿活动
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务