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)

Hinduism

Q&A for followers of the Hindu religion and those interested in learning more about Hinduism

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 to meta site
loading Hold tight while we fetch your results