Select & count

Hi,

I need some assistance on selecting and counting records from a database.

Every record in the table will have a category example ‘News’ and ‘Sport’. Let say News has 17 category’s and sport has 11. How can I list all category’s and count the total amount of records within that category.

so. . .

      News (17)
      Sport (11)

[FONT=verdana]Hmm. Not sure if I understand the question.

You say “Every record in the table will have a category example ‘News’ and ‘Sport’.” But you also say “Let say News has 17 category’s and sport has 11.” If a record has a category named News, how can News have 17 categories?

Do you mean that there might be 17 records for which News is the category?

If so, then to get the number of records in each category, you would do something like this:

SELECT Category, COUNT(*) FROM TheTable GROUP BY Category

Does that answer you question?

Mike
[/FONT]

Not really an ASP problem. You may want to post this to an SQL forum They do this type of problem all day long.

Thread moved to the databases forum

all day, and all of the night

Off Topic:

bonus points if you can name that song

The song was in my head, but couldn’t think of who it way by. I’m not posting since I had to look it up. :slight_smile: