-
-
Save carinavockell/69695a22c8a34678044fd1db1b311bd3 to your computer and use it in GitHub Desktop.
These built-in T-SQL functions provide the same functionality as the query above but with less complicated coding and more efficiency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
SalesOrderDetailID, | |
UnitPrice, | |
CarrierTrackingNumber, | |
RunningTotal = SUM (UnitPrice) OVER ( | |
PARTITION BY CarrierTrackingNumber ORDER BY SalesOrderDetailID), | |
RowCnt= COUNT (*) OVER ( | |
PARTITION BY CarrierTrackingNumber ORDER BY SalesOrderDetailID) | |
FROM Sales.SalesOrderDetail o | |
WHERE o.CarrierTrackingNumber IS NOT NULL | |
ORDER BY CarrierTrackingNumber ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment