Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created February 29, 2016 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radityopw/06ef383f03fc15ece9af to your computer and use it in GitHub Desktop.
Save radityopw/06ef383f03fc15ece9af to your computer and use it in GitHub Desktop.
use AdventureWorks2012
go
WITH Sales_CTE
AS
(
SELECT SalesPersonID, COUNT(*) as JML_ORDER
FROM Sales.SalesOrderHeader
WHERE SalesPersonID IS NOT NULL
GROUP BY SalesPersonID
)
SELECT AVG(JML_ORDER) AS "Average Sales Per Person"
FROM Sales_CTE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment