Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.57 KB | None | 0 0
  1. SELECT c.Name "Nazwa", CAST(YEAR(sod.ModifiedDate) AS NCHAR) "Rok",
  2. CAST(round(100 * SUM(sod.LineTotal) /
  3. (SUM(SUM(sod.LineTotal)) OVER(partition BY c.ProductCategoryID)), 2) AS DECIMAL(10,2)) "Procent"
  4. FROM Sales.SalesOrderDetail sod JOIN Production.Product p ON sod.ProductID = p.ProductID
  5. JOIN Production.ProductSubcategory sc ON p.ProductSubcategoryID = sc.ProductSubcategoryID
  6. JOIN Production.ProductCategory c ON sc.ProductCategoryID = c.ProductCategoryID
  7. WHERE c.Name = 'Bikes'
  8. GROUP BY c.Name, YEAR(sod.ModifiedDate), c.ProductCategoryID
  9. UNION
  10. SELECT '', '', 100;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement