select sum(amount_purchase) as amount ,list_purchase
from purchase_history
where year(date_purchase)='YYYY'
group by list_purchase
2.หารายการที่ขายได้น้อยที่สุด 2 อันดับ
Code
select top 2 * from
(
select sum(amount_purchase) as amount ,list_purchase
from purchase_history
where year(date_purchase)='YYYY'
group by list_purchase
) b
order by b.amount asc