Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number & Subnumber 1

Status
Not open for further replies.

georgesOne

Technical User
Joined
Jul 2, 2004
Messages
176
Location
JP
Hi everybody,

I would like to have a query which gives a result with # increments and sub# increments as follows (only Name is part of the underlying table)

# Sub# Name
1 1 Ali
2 2 Anton
3 1 Barton
4 2 Beaver
5 3 Bertha
6 1 Christine etc

No idea where to start, especially for the sub#.

Any hint is appreciated.

Kind regards, Georges
 
Typed, untested:
Code:
SELECT (SELECT Count(*) FROM tblName WHERE Name<=N.Name) AS [Number]
, (SELECT Count(*) FROM tblName WHERE Name<=N.Name AND Left(Name,1)=Left(N.Name,1)) AS SubNumber
, Name
FROM tblName AS N

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
As always... thanks a lot, PH.My query is somewhat more complicated (multiple joins) so I need to find out how to implement your suggestion.Anyway, very good start.Regards, Georges
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top