daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select distinct  p.Name "nazwa", year(OrderDate) "rok",
  2.     sum(soh.SubTotal) over(partition by p.Name, year(OrderDate)) "suma",
  3.     sum(SubTotal) over(partition by p.Name, year(OrderDate)) / sum(SubTotal) over()*100 "udział %"
  4. from Sales.SalesOrderHeader soh
  5.     join Sales.SalesOrderDetail sod on
  6.     soh.SalesOrderID = sod.SalesOrderID
  7.     join Sales.SpecialOfferProduct sop on
  8.     sod.SpecialOfferID = sop.SpecialOfferID
  9.     join Production.Product p on
  10.     sop.ProductID = p.ProductID
  11.     join Production.ProductSubcategory ps on
  12.     p.ProductSubcategoryID = ps.ProductSubcategoryID
  13.     join Production.ProductCategory pc on
  14.     ps.ProductCategoryID = pc.ProductCategoryID
  15. where pc.Name = 'Bikes'
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