PDA

View Full Version : help with count() and group by


kairog
07-25-2008, 04:13 PM
Hi all,

I want to get all rows from a table where entry for each ID equals 15

I tried this sql command:
select ID, count(ID) as count from IDentries group by ID

But it extracts all rows with total count for each ID.

I'm looking at only those ID's that are entered into the table 15 times. those ID's with less than 15 should not be fetched.

Any fitting sql statements?

Cheers,
Kairog :)

PeaTearGriffin
07-25-2008, 04:36 PM
I think adding "HAVING count(ID) >= 15" to the end of your query should work.

kairog
07-25-2008, 04:42 PM
Thank you PeaTearGriffin that perfectly fits! :)