SELECT SalesOrderID, 
ROW_NUMBER() OVER
(
PARTITION BY SalesOrderID
ORDER BY LineTotal
) [Row Number],
LineTotal,
SalesOrderDetailID
FROM Sales.SalesOrderDetail
ORDER BY SalesOrderID, LineTotal
a
b
c
d
