Advertisement
hecrus

demo2 progress

Oct 17th, 2020 (edited)
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.58 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[dashboard_tst-dashboard_progressProducts_getPanelTable]
  2.     @username nvarchar(128)
  3. AS
  4. BEGIN
  5.     declare @maxProduct int
  6.     select top 1 @maxProduct = (select sum(cnt) from tst_orders where productID = tst_products.id)
  7.     from tst_products
  8.     order by (select sum(cnt) from tst_orders where productID = tst_products.id) desc
  9.    
  10.     select name Title,
  11.            @maxProduct / 100 * (select sum(cnt) from tst_orders where productID = tst_products.id) Value
  12.     from tst_products
  13.     where (select sum(cnt) from tst_orders where productID = tst_products.id) > 0
  14. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement