SHARE
TWEET

Untitled

a guest Mar 20th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT Podkategoria,  Produkt,
  2.             Sum(Kwota) OVER(PARTITION BY Podkategoria, Produkt) AS "Kwota",
  3.             Sum(Kwota) OVER (PARTITION BY Podkategoria ORDER BY Produkt ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS "Suma narastająco"
  4. FROM(
  5.     SELECT PSC.Name AS "Podkategoria", P.Name AS "Produkt",  Sum(SOD.LineTotal) AS "Kwota"
  6.             --Sum(SOD.LineTotal) OVER(PARTITION BY PSC.Name, P.Name) AS "Kwota",
  7.             --Sum(SOD.LineTotal) OVER (PARTITION BY PSC.Name, P.Name ORDER BY P.Name ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS "Suma narastająco"
  8.     FROM Sales.SalesOrderDetail AS "SOD"
  9.          RIGHT JOIN Production.Product AS "P" ON(SOD.ProductID = P.ProductID)
  10.          JOIN Production.ProductSubcategory AS "PSC" ON(P.ProductSubcategoryID = PSC.ProductSubcategoryID)
  11.     GROUP BY P.Name, PSC.Name) AS "t"
  12.     --ORDER BY PSC.Name, Sum(SOD.LineTotal);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top