SELECT ngaynhap, [B2M, NT240]
FROM (select SUM(soluong ) as soluong, ngaynhap, macummay from view_nanglucsx_dinhphoi where ngaynhap>='01/01/2015' and ngaynhap<='01/01/2016' group by ngaynhap, macummay) as source
PIVOT (SUM(soluong) FOR macummay IN ([B2M, NT240])) as PVT order by ngaynhap ASC.
Chúc các bạn thành công