Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    1

    Unanswered: 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.

  2. #2
    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


    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •