View Single Post
  #2 (permalink)  
Old 07-02-2008, 05:04 PM
Jeremias Spoken Jeremias Spoken is offline
Junior Member
 
Join Date: Jun 2008
Posts: 5
Jeremias Spoken is on a distinguished road
Default ANY answer. Re: Row Number Each Group

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...!
Reply With Quote