SHARE
TWEET

Untitled

a guest Mar 24th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT DISTINCT
  2. P.FirstName + ' ' + P.LastName AS Klient,
  3. YEAR(SOH.OrderDate) AS Rok,
  4. MONTH(SOH.OrderDate) AS Miesiac,
  5. COUNT(*)
  6. OVER(PARTITION BY C.CustomerID, YEAR(SOH.OrderDate),
  7. MONTH(SOH.OrderDate)) AS [W misiacu],
  8. COUNT(*) OVER(PARTITION BY C.CustomerID, YEAR(SOH.OrderDate)) "W roku",
  9. COUNT(*) OVER(PARTITION BY C.CustomerID, YEAR(SOH.OrderDate) ORDER BY
  10. MONTH(SOH.OrderDate)) AS "W roku narastajaco"
  11. FROM Sales.Customer C
  12. JOIN Person.Person P ON C.PersonID = P.BusinessEntityID
  13. LEFT JOIN Sales.SalesOrderHeader SOH ON C.CustomerID = SOH.CustomerID
  14. LEFT JOIN Sales.SalesOrderDetail SOD ON SOH.SalesOrderID = SOD.SalesOrderID
  15. Order By 1,2,3
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