Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT isnull(c.Name, '') "Nazwa", isnull(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 GROUPING sets((c.Name, YEAR(sod.ModifiedDate), c.ProductCategoryID), ())
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement