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)

Psychology and Neuroscience

Q&A for practitioners, researchers, and students in cognitive science, psychology, neuroscience, and psychiatry

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


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

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results