Number limiting query

ariansman

Registered User.
Local time
Yesterday, 23:19
Joined
Apr 3, 2012
Messages
157
In table1 students lectures data are stored as:
Code:
ID     studentname      lecturesubject      lecturedate
1         steve            politics          3/2/2013 
2         jack             politics          3/2/2013 
3         steve            math              5/2/2013 
4         steve            politics          7/2/2013 
5         jack             politics          8/2/2013 
6         steve            math              8/2/2013 
7         jack             politics          9/2/2013 
8         steve            politics          10/2/2013 
9         steve            math              11/2/2013 
10        steve            physics           13/2/2013 
11        jack             politics          15/2/2013
We need a query in which for each student is allowed to preset a limited number of lectures on a specific subject. For example each student can provide only two lectures on a subject and any more lectures on the same subject presented by him will not be counted. In the above example records 7 8 9 and 11 will not be shown in the query.
Thank you
 
thank you, but i was am so naive..
can you let me know about the sql to run this query?
tnx
 
Air code..
Code:
SELECT StudentName, LectureSubject FROM theTableName
GROUP BY StudentName, LectureSubject
HAVING Count(ID) <=2;
 

Users who are viewing this thread

Back
Top Bottom