Try this query:
SELECT ItemCode, WhsCode,ROW_NUMBER()OVER (PartitionBY ItemCode OrderBy WhsCode)- 1 FROM OITW
This query will give you the LineNum based on the system keeping the order as alphabetical order on the WhsCode.
Try this query:
SELECT ItemCode, WhsCode,ROW_NUMBER()OVER (PartitionBY ItemCode OrderBy WhsCode)- 1 FROM OITW
This query will give you the LineNum based on the system keeping the order as alphabetical order on the WhsCode.