Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT c.Name "Nazwa", CAST(YEAR(sod.ModifiedDate) AS NCHAR) "Rok",
- CAST(round(100 * SUM(sod.LineTotal) /
- (SUM(SUM(sod.LineTotal)) OVER(partition BY c.ProductCategoryID)), 2) AS DECIMAL(10,2)) "Procent"
- FROM Sales.SalesOrderDetail sod JOIN Production.Product p ON sod.ProductID = p.ProductID
- JOIN Production.ProductSubcategory sc ON p.ProductSubcategoryID = sc.ProductSubcategoryID
- JOIN Production.ProductCategory c ON sc.ProductCategoryID = c.ProductCategoryID
- WHERE c.Name = 'Bikes'
- GROUP BY c.Name, YEAR(sod.ModifiedDate), c.ProductCategoryID
- UNION
- SELECT '', '', 100;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement