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

Easy Question?

Status
Not open for further replies.

Toby1kenobe

Instructor
May 26, 2002
66
GB
Hi

I want to count how many times each student name appears in a table. Those that appear >= 3 will show on a report.

Sounds easy but it's giving me a headache (I'm slogging through SQL, and getting their slowly!!)

Any help is as always greatly appreciated

Toby
 
Select StudentName, count(StudentName)
From Table
Having count(StudentName) >= 3
Group By StudentName

Something like this should work but I don't know what your table structure is like ...

Transcend
[gorgeous]
 
HI

Thanks for the rapid response! I tried you're suggestion and it did'nt like the 'Having' statement. I'm using Access, could that be the problem?

Thanks Again
Toby
 
Think it should be like this: (the group by BEFORE the having).

Select StudentName, count(StudentName)
From Table
Group By StudentName
Having count(StudentName) >= 3



 
Thanks Again

having the HAVING after the GROUP has done the trick

Thanks
Toby
 
Ah sorry about that wrote it backwards!

Clandon the HAVING clause specifies a search condition for a group or an aggregate like count(StudentName) sum(number) etc etc.

Transcend
[gorgeous]
 
Thanks Transcend. I'm learning and thought maybe it was an Access SQL thing, but you just taught me otherwise.

Glad I still learn something new everyday!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top