Hi hail...!
Here the solution (DB2):
[sql]
SELECT C.CTA, ROW#
FROM TABLENAME C,
TABLE
(SELECT COUNT(*) AS ROW#
FROM TABLENAME C2
WHERE C2.CTA = C.CTA AND C2.CTA1 <= C.CTA1) AS TABLENAME_ORDER
ORDER BY C.CTA, ROW#;
[/sql]In this T-SQL CTA1 is another field different that CTA.
Follow next link for 2 ways in SQLServer:
tek-tips forums
Best regards...!