Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created February 29, 2016 07:33
Show Gist options
  • Save radityopw/bbb4878de1661e33b785 to your computer and use it in GitHub Desktop.
Save radityopw/bbb4878de1661e33b785 to your computer and use it in GitHub Desktop.
use AdventureWorks2012
go
select * from
(
SELECT SalesPersonID, COUNT(*) as JML_ORDER
FROM Sales.SalesOrderHeader
WHERE SalesPersonID IS NOT NULL
GROUP BY SalesPersonID
) a
where jml_order > (
SELECT AVG(JML_ORDER) AS rata_order
from (
SELECT SalesPersonID, COUNT(*) as JML_ORDER
FROM Sales.SalesOrderHeader
WHERE SalesPersonID IS NOT NULL
GROUP BY SalesPersonID
) b
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment