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

Help Counting An Item

Status
Not open for further replies.

furtech

IS-IT--Management
Oct 19, 2003
96
AU
Hello,

I was wondering if someone could tell the correct way to go about using the count statement within a select query. I want to count students attempts at taking an exam but only show users who have done it more than 3 times...

Table: Student_Attempts
Stu_Name Attempts
Bob 3
Mary 6
Sam 8
Jane 1

Its the more than 3 times part that I'm stuck on.

Thanks,

Matthew
 
Emplying the use of 'HAVING'. The group by probably should be changed to a real primary key instead of Stu_Name which may not be unique per student.

Code:
SELECT Stu_Name, COUNT(*) AS Attempts FROM Student_Attempts GROUP BY Stu_Name HAVING Attempts >= 3;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top