Skip to content

Instantly share code, notes, and snippets.

@anibihakeem
Last active December 14, 2023 10:39
Show Gist options
  • Select an option

  • Save anibihakeem/6e7104b0ca3a0e069539358f616b2a4e to your computer and use it in GitHub Desktop.

Select an option

Save anibihakeem/6e7104b0ca3a0e069539358f616b2a4e to your computer and use it in GitHub Desktop.
SELECT H.CustomerID, AVG(D.OrderQty) Avg_quantity, ROUND(AVG(D.LineTotal),2) AS Avg_Amount
FROM Sales.SalesOrderHeader AS H
JOIN Sales.SalesOrderDetail AS D ON H.SalesOrderID = D.SalesOrderID
GROUP BY CustomerID
ORDER BY Avg_Amount DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment