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)

Robotics

Q&A for professional robotic engineers, hobbyists, researchers and students

CREATE TABLE #yt
    ([Store] int, [Week] int, [xCount] int, [TEST] INT)
;
    
INSERT INTO #yt
    ([Store], [Week], [xCount], TEST)
VALUES
   
    (105, 1, 37,3),
   
    (105, 2, 78, 5)
   
    
;


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

Enter Parameters

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