select a.item_id,b.buyer_id
from
(
select item_id,max(sum(amt)) as max_sum_amt
from A
where dt>=201807 and dt<=201809
and buyer_id=123
group by 1
)a
left join 
(
select item_id,buyer_id,max(sum(amt)) as max_sum_amt
from A
where dt>=201807 and dt<=201809
group by 1,2
) b on a.item_id=b.item_id