Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30

    Group By

    Hello,




    I am brand new to forum, but have been writing simple Access quires for many years. My population is a group of students with grades. I want to be able to only select those students that have 3 or more passing grades. So for example if a student has 3 passing grades A, B or C and two failing grades how can I select only those students with 3 or or more passing grades and if there are many students in this group, how can I only get those with 3 or more?


    Make sense?


    Thanks for your help!

    Deano

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Show readers your table designs.
    What have you tried?

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Do you also want the students with 3 or more passing grades even if they have failing grades?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30
    Sure, as long as I can make sure they have at least three failing or three passing grades.

    Thanks

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Now I am really confused - all students with 3 passing OR 3 failing? Maybe you better show an example of raw data and output you want.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30
    Why don’t we just say, if a student has 5 courses and passed at least thee of them. I want to know any student that passed basically with a grade do D or higher in at least three courses.

    Make sense?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Consider:

    SELECT StudentGrades.Student, Sum(IIf([Grade]<="d",1,0)) AS PassCount
    FROM StudentGrades
    GROUP BY StudentGrades.Student
    HAVING (((Sum(IIf([Grade]<="d",1,0)))>=3));
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30
    As I think about this some more, I think what I would like to be able show all the students grades, but figure out a way to desperate out students that have at least 3 of the bad grades mentioned above. So find a way to group these students that have a least 3 bad grades, but also show any passing grade.

    Make sense?

    Thanks!

  9. #9
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30
    Here is a sample of the database.

    SELECT TblHotWaterTest_2.Term, TblHotWaterTest_2.Last, TblHotWaterTest_2.First, TblHotWaterTest_2.Subj, TblHotWaterTest_2.Crse, TblHotWaterTest_2.Grade
    FROM TblHotWaterTest_2
    ORDER BY TblHotWaterTest_2.Last, TblHotWaterTest_2.First;

    I need to change something to get these to group those students with at least three bad grades, but still show all there grades. If possible.
    Thanks,

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    There is no db attached.

    Started out wanting to show students with 3 passing grades and now the criteria is 3 bad grades???

    Is there a StudentID field in table?

    SELECT * FROM TblHotWaterTest_2 ORDER BY DCount("*", "TblHotWaterTest_2", "StudentID=" & [StudentID] & " AND Grade='F'"), StudentID;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30
    Sorry it has taken so long to post this. Again, if possible, for this population, I only want those students that have at least 3 bad grades, but also include all of their grades. So one test student, Bob Smith has 3 bad grades but also one passing grade. We need to separate students with at least three bad grades. Bill Kane also has a good grade but at least 3 bad grades.

    How to do I attach a database?

    Thanks!

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Did you try any of the suggestions?

    Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30

    Attached Database

    Grade Test.accdbI did, but i haven't had too much luck.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What do FA and W grades mean? Are they failing? Bob Smith has 4 F, 1 FA, 1 W, 1 C+; Bill Kane has 3 F, 1 W, 1 B. The following queries return those 12 records as no one else has 3 or more F.

    Revision of my last suggestion:

    SELECT TblHotWaterTest_2.*, DCount("*","TblHotWaterTest_2","[Last] & [First]='" & [Last] & [First] & "' AND Grade='F'") AS CountFail
    FROM TblHotWaterTest_2
    WHERE (((DCount("*","TblHotWaterTest_2","[Last] & [First]='" & [Last] & [First] & "' AND Grade='F'"))>=3))
    ORDER BY TblHotWaterTest_2.[Last] & [First];

    or

    SELECT TblHotWaterTest_2.*
    FROM TblHotWaterTest_2
    WHERE ((([Last] & [First]) In (SELECT [LAST] & [First] FROM TblHotWaterTest_2 GROUP BY [Last] & [First] HAVING Sum(IIf([Grade]="F",1,0))>=3)))
    ORDER BY [Last] & [First];

    Names make very poor unique identifiers.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Dean0_53 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    30
    Yes W-Withdrawn and FA-Failure lack of attendance. Basically and grade lower then D-.

    Thanks,

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-26-2016, 01:07 PM
  2. Replies: 2
    Last Post: 01-27-2016, 08:38 AM
  3. Replies: 6
    Last Post: 06-09-2015, 09:51 AM
  4. Replies: 3
    Last Post: 04-28-2015, 02:16 AM
  5. Replies: 0
    Last Post: 02-25-2013, 04:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums