hecrus

Demo 2 Line

Oct 17th, 2020
2,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.97 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[dashboard_tst-dashboard_lineSumOrders_getPanelChart]
  2. @username nvarchar(128)
  3. AS
  4. BEGIN
  5.     declare @days nvarchar(max)
  6.     select @days = '13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28'
  7.    
  8.     declare @ndays table (n int)
  9.     insert into @ndays
  10.     select value from dbo.split(@days,',') where value <> 0
  11.  
  12.     select 'line' Type,
  13.            '' Title,
  14.            400 Width,
  15.            400 Height,
  16.            @days as CommaLabels
  17.    
  18.     select 'March 2020' Title,
  19.             (select stuff( (
  20.                         select ','+ X
  21.                           from (select isnull(cast((select cast(sum(cnt*price) as int)
  22.                                                     from tst_orders where created between '2020/03/13' and '2020/03/28'
  23.                                                     and day(created) = n) as nvarchar),'0') as X
  24.                                 from @ndays) t1
  25.                         for xml path(''), type
  26.                            ).value('.', 'varchar(max)'), 1, 1, ''
  27.                          )
  28.             ) Value,
  29.            '#6610f2' Color
  30. END
Add Comment
Please, Sign In to add comment