If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Simple SQL query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-12-03, 06:25
ajeeves ajeeves is offline
Registered User
 
Join Date: Aug 2003
Posts: 1
Simple SQL query

Hi,

I'm newish to sql and i need to do a query but am not too sure how.

Say i have a table with a column called 'name' how could i count the number of different names in the table, ie have a result like:

Name Count
Alan 5
Steve 4
...

Where there would be 5 records in the table that had the name Alan and 4 with Steve...

Can someone please help me out here. Hope you know what i mean.

Thanks very much,
Alan.
Reply With Quote
  #2 (permalink)  
Old 08-12-03, 15:15
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
Re: Simple SQL query

Give this a try:

select name, count(*) from table
group by name


Quote:
Originally posted by ajeeves
Hi,

I'm newish to sql and i need to do a query but am not too sure how.

Say i have a table with a column called 'name' how could i count the number of different names in the table, ie have a result like:

Name Count
Alan 5
Steve 4
...

Where there would be 5 records in the table that had the name Alan and 4 with Steve...

Can someone please help me out here. Hope you know what i mean.

Thanks very much,
Alan.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On