Can you try this?
[code language="T-SQL"]
SELECT DISTINCT a.CodeNo, c.SubjectID, c.SubjectTitle, c.LabUnits, c.LecUnits, c.TFRFROM sample.dbo.Class aINNER JOIN sample.dbo.Codes b ON a.CodeNo = b.CodeNo AND a.SchoolYear = b.SchoolYearINNER JOIN sample.dbo.Subject c ON c.SubjectID = b.SubjectID LEFT JOIN sample.dbo.Curriculum d ON ( c.ProgramID = d.ProgramID AND b.ProgramID = c.ProgramID )
[/code]
keithrull:Can you try this? [code language="T-SQL"] SELECT DISTINCT a.CodeNo, c.SubjectID, c.SubjectTitle, c.LabUnits, c.LecUnits, c.TFRFROM sample.dbo.Class aINNER JOIN sample.dbo.Codes b ON a.CodeNo = b.CodeNo AND a.SchoolYear = b.SchoolYearINNER JOIN sample.dbo.Subject c ON c.SubjectID = b.SubjectID LEFT JOIN sample.dbo.Curriculum d ON ( c.ProgramID = d.ProgramID AND b.ProgramID = c.ProgramID ) [/code]
trashVin: keithrull: Can you try this? [code language="T-SQL"] SELECT DISTINCT a.CodeNo, c.SubjectID, c.SubjectTitle, c.LabUnits, c.LecUnits, c.TFRFROM sample.dbo.Class aINNER JOIN sample.dbo.Codes b ON a.CodeNo = b.CodeNo AND a.SchoolYear = b.SchoolYearINNER JOIN sample.dbo.Subject c ON c.SubjectID = b.SubjectID LEFT JOIN sample.dbo.Curriculum d ON ( c.ProgramID = d.ProgramID AND b.ProgramID = c.ProgramID ) [/code] hey bro.. i tested the script you just posted the number of returned records were almost multiplied by 7.the curriculum table shld not be included in the testing for programids it should be only within the codes and subject table .thanks anyway...hope to find the solution in several days im looking at possiblities of using 2 views to separate the codes with nul and thoses that does not have null values...
keithrull: Can you try this? [code language="T-SQL"] SELECT DISTINCT a.CodeNo, c.SubjectID, c.SubjectTitle, c.LabUnits, c.LecUnits, c.TFRFROM sample.dbo.Class aINNER JOIN sample.dbo.Codes b ON a.CodeNo = b.CodeNo AND a.SchoolYear = b.SchoolYearINNER JOIN sample.dbo.Subject c ON c.SubjectID = b.SubjectID LEFT JOIN sample.dbo.Curriculum d ON ( c.ProgramID = d.ProgramID AND b.ProgramID = c.ProgramID ) [/code]
I see... i think i just followed the first select on top when i extracted this query. will try again later :)
Try this:
SELECT DISTINCT a.CodeNo, c.SubjectID, c.SubjectTitle, c.LabUnits, c.LecUnits, c.TFRFROM sample.dbo.Class aINNER JOIN sample.dbo.Codes b ON a.CodeNo = b.CodeNo AND a.SchoolYear = b.SchoolYearLEFT JOIN sample.dbo.Subject c ON c.SubjectID = b.SubjectID AND c.ProgramID = b.ProgramIDLEFT JOIN sample.dbo.Curriculum d ON ( c.ProgramID = d.ProgramID )
And also this:
SELECT DISTINCT a.CodeNo, c.SubjectID, c.SubjectTitle, c.LabUnits, c.LecUnits, c.TFRFROM sample.dbo.Class aINNER JOIN sample.dbo.Codes b ON a.CodeNo = b.CodeNo AND a.SchoolYear = b.SchoolYearLEFT JOIN sample.dbo.Subject c ON c.SubjectID = b.SubjectID AND c.ProgramID = b.ProgramID
I have removed the INNER JOIN on Curriculum since it is not being used on our select statement.