CREATE TABLE #yt ([Store] int, [Week] int, [xCount] int) ;

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy Meta

Q&A about the site for science fiction and fantasy enthusiasts

CREATE TABLE #yt
    ([Store] int, [Week] int, [xCount] int)
;
    
INSERT INTO #yt
    ([Store], [Week], [xCount])
VALUES
    (102, 1, 96),
    (101, 1, 138),
    (105, 1, 37),
    (109, 1, 59)
;

--select * from #yt

select * 

from 
(
  select store, week, xCount
  from #yt
) src
pivot
(
sum(xcount)
  for week in ([1], [2], [3])
) piv;

Enter Parameters

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