Skip to content

Instantly share code, notes, and snippets.

@gsampath127
Created October 11, 2019 19:58
Show Gist options
  • Save gsampath127/2cd88e19590021cf4717835805350cf5 to your computer and use it in GitHub Desktop.
Save gsampath127/2cd88e19590021cf4717835805350cf5 to your computer and use it in GitHub Desktop.
SELECT ProductName,
TotalAmout,
sum([TotalAmout]) OVER(ORDER BY ProductName) AS RunningTotal
FROM
(SELECT prod.ProductName,
sum(ord.Quantity*ord.UnitPrice) [TotalAmout]
FROM [Order Details] ord
INNER JOIN Products prod ON ord.ProductID=prod.ProductID
GROUP BY prod.ProductName) p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment