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]) VALUES (102, 1), (101, 2), (105, 3) ; select * from ( select store, week from #yt ) src pivot ( sum(Store) for week in ([1], [2], [3]) ) piv;