CREATE TABLE #yt ([LOAITS] nvarchar(50), [TONGSL] int, [T...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Sitecore Meta

Q&A about the site for developers and end users of the Sitecore CMS and multichannel marketing software

CREATE TABLE #yt
([LOAITS] nvarchar(50), [TONGSL] int, [TONGTIEN] int )
;
    
INSERT INTO #yt
    ([LOAITS], [TONGSL], [TONGTIEN])
VALUES
    ('a1', 1, 96),
    ('a1', 1, 138),
    ('a2', 2, 37),
    ('a2', 2, 59),
    ('a3', 1, 282),
    ('a3', 3, 212)
;


select *
from 
(
  select LOAITS, TONGSL, TONGTIEN
  from #yt
) src
pivot
(
sum(TONGSL)
  for LOAITS in ([1], [2], [3])
) piv;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results