daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT YEAR(CONVERT(DATE,OrderDATE))'Rok' ,
  2.     (
  3.     SELECT COUNT(CustomerID)
  4.     FROM Sales.SalesOrderHeader
  5.     WHERE MONTH(CONVERT(DATE,OrderDATE))=1 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  6.     )'1',
  7.     (
  8.     SELECT COUNT(CustomerID)
  9.     FROM Sales.SalesOrderHeader
  10.     WHERE MONTH(CONVERT(DATE,OrderDATE))=2 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  11.     )'2',
  12.     (
  13.     SELECT COUNT(CustomerID)
  14.     FROM Sales.SalesOrderHeader
  15.     WHERE MONTH(CONVERT(DATE,OrderDATE))=3 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  16.     )'3',
  17.     (
  18.     SELECT COUNT(CustomerID)
  19.     FROM Sales.SalesOrderHeader
  20.     WHERE MONTH(CONVERT(DATE,OrderDATE))=4 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  21.     )'4',
  22.     (
  23.     SELECT COUNT(CustomerID)
  24.     FROM Sales.SalesOrderHeader
  25.     WHERE MONTH(CONVERT(DATE,OrderDATE))=5 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  26.     )'5',
  27.     (
  28.     SELECT COUNT(CustomerID)
  29.     FROM Sales.SalesOrderHeader
  30.     WHERE MONTH(CONVERT(DATE,OrderDATE))=6 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  31.     )'6',
  32.     (
  33.     SELECT COUNT(CustomerID)
  34.     FROM Sales.SalesOrderHeader
  35.     WHERE MONTH(CONVERT(DATE,OrderDATE))=7 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  36.     )'7',
  37.     (
  38.     SELECT COUNT(CustomerID)
  39.     FROM Sales.SalesOrderHeader
  40.     WHERE MONTH(CONVERT(DATE,OrderDATE))=8 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  41.     )'8',
  42.     (
  43.     SELECT COUNT(CustomerID)
  44.     FROM Sales.SalesOrderHeader
  45.     WHERE MONTH(CONVERT(DATE,OrderDATE))=9 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  46.     )'9',
  47.     (
  48.     SELECT COUNT(CustomerID)
  49.     FROM Sales.SalesOrderHeader
  50.     WHERE MONTH(CONVERT(DATE,OrderDATE))=10 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  51.     )'10',
  52.     (
  53.     SELECT COUNT(CustomerID)
  54.     FROM Sales.SalesOrderHeader
  55.     WHERE MONTH(CONVERT(DATE,OrderDATE))=11 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  56.     )'11',
  57.     (
  58.     SELECT COUNT(CustomerID)
  59.     FROM Sales.SalesOrderHeader
  60.     WHERE MONTH(CONVERT(DATE,OrderDATE))=12 AND YEAR(CONVERT(DATE,OrderDATE)) = YEAR(CONVERT(DATE,res.OrderDate))
  61.     )'12'
  62. FROM Sales.SalesOrderHeader res
  63. GROUP BY YEAR(CONVERT(DATE,OrderDATE))
  64. ORDER BY 1
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