Please support our Database Design advertiser: Programming Forums
•
•
Join Date: Sep 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
I wish to extract a class list of students with assessment details on for a given term. The report must list all of the student names for the specified group, along with the assessment information for that term if it exists, otherwise the assessment part should be blank.
I am using the following query:
SELECT s.AdmissionNo, s.Surname, s.Forename, t.Progress, t.Effort, t.Behaviour, t.Classwork, t.Homework FROM Lessons l
INNER JOIN Students s ON l.AdmissionNo=s.AdmissionNo
LEFT OUTER JOIN Reports_Termly t ON t.LessonID=l.LessonID
WHERE l.GroupRef="mat/09/MS-M1" AND t.TermID="3"
The table definitions are as follows:
CREATE TABLE `students` (
`AdmissionNo` int(11) NOT NULL default '0',
`Surname` varchar(30) NOT NULL default '',
`Forename` varchar(30) NOT NULL default '',
PRIMARY KEY (`AdmissionNo`));
CREATE TABLE `lessons` (
`LessonID` int(10) unsigned NOT NULL auto_increment,
`GroupRef` varchar(20) NOT NULL default '',
`AdmissionNo` int(11) NOT NULL default '0',
PRIMARY KEY (`LessonID`));
CREATE TABLE `reports_termly` (
`LessonID` int(10) unsigned NOT NULL default '0',
`TermID` int(10) unsigned NOT NULL default '0',
`Progress` char(1) NOT NULL default '',
`Effort` tinyint(1) unsigned NOT NULL default '0',
`Behaviour` tinyint(1) unsigned NOT NULL default '0',
`Classwork` tinyint(1) unsigned NOT NULL default '0',
`Homework` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`LessonID`,`TermID`));
However, the query mentioned above does not return the students in the group that do not have any assessment details for this term (which I require it to do).
If anyone has any suggestions on how to do this, please let me know.
Thanks in advance
Chris
I am using the following query:
SELECT s.AdmissionNo, s.Surname, s.Forename, t.Progress, t.Effort, t.Behaviour, t.Classwork, t.Homework FROM Lessons l
INNER JOIN Students s ON l.AdmissionNo=s.AdmissionNo
LEFT OUTER JOIN Reports_Termly t ON t.LessonID=l.LessonID
WHERE l.GroupRef="mat/09/MS-M1" AND t.TermID="3"
The table definitions are as follows:
CREATE TABLE `students` (
`AdmissionNo` int(11) NOT NULL default '0',
`Surname` varchar(30) NOT NULL default '',
`Forename` varchar(30) NOT NULL default '',
PRIMARY KEY (`AdmissionNo`));
CREATE TABLE `lessons` (
`LessonID` int(10) unsigned NOT NULL auto_increment,
`GroupRef` varchar(20) NOT NULL default '',
`AdmissionNo` int(11) NOT NULL default '0',
PRIMARY KEY (`LessonID`));
CREATE TABLE `reports_termly` (
`LessonID` int(10) unsigned NOT NULL default '0',
`TermID` int(10) unsigned NOT NULL default '0',
`Progress` char(1) NOT NULL default '',
`Effort` tinyint(1) unsigned NOT NULL default '0',
`Behaviour` tinyint(1) unsigned NOT NULL default '0',
`Classwork` tinyint(1) unsigned NOT NULL default '0',
`Homework` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`LessonID`,`TermID`));
However, the query mentioned above does not return the students in the group that do not have any assessment details for this term (which I require it to do).
If anyone has any suggestions on how to do this, please let me know.
Thanks in advance
Chris
Similar Threads
Other Threads in the Database Design Forum
- SQL Queries help (Database Design)
- Wordpress, Joins and Indexes (MySQL)
- generating one report from multiple tables (Visual Basic 4 / 5 / 6)
- MS SQL Joins - newb assistance (MS SQL)
- Process very slow - SQL Database (MS SQL)
- Problem with Rewriting Subqueries as Joins (Database Design)
- Query conversion from Sybase to MS SQL Server 2000 (MS SQL)
- Problem with Rewriting Subqueries as Joins (MS SQL)
Other Threads in the Database Design Forum
- Previous Thread: NEED SQL Homework HELP-DESPERATE!
- Next Thread: A database with categories and subcategories
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Threaded Mode