Question : Query Question

The query in the code snippet gives the following result, however, I am looking for a new way to tackle the problem.

To test:
Please type in 07/01/09 and 07/31/09 as Begin and End Dates

GroupID    CourseID      CountofRID
ASL             MTH                 5
CFT             EAT                  1
LT               GYM                 2
STU             CHM                9
STU             GYM                10
STU             MTH                24
STU             PHY                13
_________________________

From the above, I will probably need 4 separate queries each based on the course(s) and maybe 2 custom functions (1 to put the Groups of the same course together, and the other to put the courses (chem & phys) of the STU group together.  Then I may need to union those 4 queries together to get my final result.  I dont expect it to be a pretty solution but I want to explore the possibility.

In other words, Is it possible to create queries that  will group the GroupID such that we can instruct the query to group all [GType] items
      where [Course] = Math......for example (see below).

1.       Group [GroupID]  In('LT','STU') WHERE Couse = "GYM"

2.       Group [GroupID]  In('ASL','STU') WHERE Couse = "Math"

3.       Group [GroupID]  In('STU') WHERE Couse = "Physics", "Chemistry"

4.       Group [GroupID]  In('CFT') WHERE Couse = "Eat"

***Result expected if evrything works out fine.****

GType                                       Course                             CountofRID
Cafeteria                                    Eat                                       1
Lecturer, Student                       Gym                                    12
Assit Lecturer, Student              Math                                   29
Students                                   Physiscs, Chemistry             22

Answer : Query Question

Strictly seen, this is a duplicate question. Those should be avoided; if there a valid answers, the questions are not allowed to sum up to more than 500 points alltogether. However, I reckon the approaches are that different that we can pass, as an exception.

My solution took that long because Access is very, very delicate about the SQL syntax, not allowing for alternative notations. It made me doubt on my own SQL knowledge :(
However, this is my solution, which is similar, but not the same:

select GrpName, count(CCon) as Cnt
from (
select GrpName, 0 as CCon
  from tblGrpNames inner join  blMain
      on tblGrpNames.Grp=tblMain.GroupID and tblGrpNames.Course=tblMain.CourseID
  where   nz(tblMain.CCon, 'No') = 'No'
     and Appdate Between forms!frmReportDateRange!BeginDate
                                      and forms!frmReportDateRange!EndDate

 union all
select distinct GrpName, 1 as cnt
  from tblGrpNames inner join  blMain
       on tblGrpNames.Grp=tblMain.GroupID and tblGrpNames.Course=tblMain.CourseID
  where   nz(tblMain.CCon, 'No') = 'Yes'
     and Appdate Between forms!frmReportDateRange!BeginDate
                                      and forms!frmReportDateRange!EndDate
)
group by GrpName

Random Solutions  
 
programming4us programming4us