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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

most efficient way to count

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
What would be the most efficient way to count how many records there are for each last name of a user from A-Z

ie:

A: 30 users
B: 10 users
C: 22 users


etc

Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
Code:
select substring(surname, 1,1), count (surname) from sometable group by substring(surname,1,1)

i think that's right. better to ask in the mysql forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top