CREATE TABLE #yt ([Store] int, [Week] int, [totalPrice] i...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Signal Processing Meta

Q&A about the site for practitioners of the art and science of signal, image and video processing

CREATE TABLE #yt
    ([Store] int, [Week] int, [totalPrice] int)
;
    
INSERT INTO #yt
    ([Store], [Week], [totalPrice])
VALUES
    (102, 1, 96),
    (101, 1, 138),
    (105, 1, 37),
    (109, 1, 59),
    (101, 2, 282),
    (102, 2, 212),
    (105, 2, 78),
    (109, 2, 97),
    (105, 3, 60),
    (102, 3, 123),
    (101, 3, 220),
    (109, 3, 87)
;

CREATE TABLE #we
([Department] char(255), 
     [SumOfSalesQ1] int, 
     [Percent2016] int, 
     [PercentTotal] int)
;
 
 declare @q1 int
 set @q1 = (select sum(totalPrice)
      from #yt
      where store = 101 and week = 1)
;

INSERT INTO #we
  ([Department], [SumOfSalesQ1], [Percent2016], [PercentTotal])
VALUES
    ('sport', @q1,
    2, 3),
    ('music' , 2, 4, 6)
;

select *
from #we

Enter Parameters

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