M
Microsoft
Hi,
I have 2 tables of data as follows:
table1: studentdata - this table stores the details of every student within
the school
fields: ID, surname, given names, year level
table2: incidentdetails - this table allows incidents to be recorded against
any student in table 1
fields: incidid (autonumber), ID, incidentdetails, incidentcode,
suspensiondate, suspendeddays, reviewed (yes/no field)
Briefly, for every incident, a student may be suspended or their incident
reviewed or both. If they are suspended, a value is entered in suspenddays
field. If they are reviewed then that field is ticked (yes selected).
The ID field joins the 2 tables
What I am having trouble with is designing a query that will return the
following information
ID, Surname, given names, count of number of suspensions, count of number of
reviews
This data is to be grouped so that students with more than one suspension do
not appear twice in the results but rather the number of reviews / incidents
they have acccrued are tallied against their name.
Sample desired output
ID, Surname, given names, count of number of incidents, count of number
of reviews
A2, ABBOTT, Mark , 1 , 2
A54, GRANT , Cheree , 2 , 0
A43, TOMS , John ,1 ,
0
This is the sql of my unsuccessful query.
SELECT incidentdetails.ID, StudentData.FamilyName, StudentData.GivenName,
StudentData.Gender, StudentData.Yearlevel, StudentData.HomeGroup,
Count(incidentdetails.ID) AS noofsuspensions, Count(incidentdetails.review)
AS CountOfReview
FROM StudentData INNER JOIN DetailsOfSuspensions ON StudentData.ID =
incidentdetails.ID
GROUP BY incidentdetails.ID, StudentData.FamilyName, StudentData.GivenName,
StudentData.Yearlevel;
Any help will be appreciated,
Thanks
Rocky
I have 2 tables of data as follows:
table1: studentdata - this table stores the details of every student within
the school
fields: ID, surname, given names, year level
table2: incidentdetails - this table allows incidents to be recorded against
any student in table 1
fields: incidid (autonumber), ID, incidentdetails, incidentcode,
suspensiondate, suspendeddays, reviewed (yes/no field)
Briefly, for every incident, a student may be suspended or their incident
reviewed or both. If they are suspended, a value is entered in suspenddays
field. If they are reviewed then that field is ticked (yes selected).
The ID field joins the 2 tables
What I am having trouble with is designing a query that will return the
following information
ID, Surname, given names, count of number of suspensions, count of number of
reviews
This data is to be grouped so that students with more than one suspension do
not appear twice in the results but rather the number of reviews / incidents
they have acccrued are tallied against their name.
Sample desired output
ID, Surname, given names, count of number of incidents, count of number
of reviews
A2, ABBOTT, Mark , 1 , 2
A54, GRANT , Cheree , 2 , 0
A43, TOMS , John ,1 ,
0
This is the sql of my unsuccessful query.
SELECT incidentdetails.ID, StudentData.FamilyName, StudentData.GivenName,
StudentData.Gender, StudentData.Yearlevel, StudentData.HomeGroup,
Count(incidentdetails.ID) AS noofsuspensions, Count(incidentdetails.review)
AS CountOfReview
FROM StudentData INNER JOIN DetailsOfSuspensions ON StudentData.ID =
incidentdetails.ID
GROUP BY incidentdetails.ID, StudentData.FamilyName, StudentData.GivenName,
StudentData.Yearlevel;
Any help will be appreciated,
Thanks
Rocky