Results 1 to 4 of 4
  1. #1
    Join Date
    May 2012
    Posts
    132

    Unanswered: Number limiting query

    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           12/2/2013 
    11        jack             politics          15/2/2013
    We need a query that allows each student 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
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    I asked god to please give me everything to enjoy the life, God said: i gave you the life to enjoy everything.

  2. #2
    Join Date
    Nov 2010
    Posts
    84
    SELECT StudentLectures.ID, StudentLectures.LectureSubject, StudentLectures.StudentName, StudentLectures.LectureDate
    FROM StudentLectures
    WHERE (((StudentLectures.ID) In (SELECT TOP 2 ID
    FROM StudentLectures AS Dupe
    WHERE Dupe.StudentName+Dupe.LectureSubject=StudentLectur es.StudentName+ StudentLectures.LectureSubject)));

  3. #3
    Join Date
    May 2012
    Posts
    132
    thank you very much. it was great
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    I asked god to please give me everything to enjoy the life, God said: i gave you the life to enjoy everything.

  4. #4
    Join Date
    Nov 2010
    Posts
    84
    I am pleased that you are happy, and the other forum visitors can take an example from my site in the signature.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •