Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 display results

Author  Topic 

ddt
Starting Member

10 Posts

Posted - 2010-05-27 : 02:28:34
i have two tables

Student schedule
StudentID classid ....
--------- -------
100 C1001
100 C1002
100 C1003
...

Grades
StudentID ClassID Grade Semester...
--------- ------- ----- --------
100 C1001 A S1
100 C1001 F S2
100 C1002 D S1
100 C1003 B S2
...

I need to join these two tables and gt results like below
Results
StudentID ClassID S1 Grade S2 Grade
--------- ------- -------- --------
100 C1001 A F
100 C1002 D
100 C1003 B
....

i joined two tables with inner join on StudentID and ClassID
Here's the actual query...
SELECT dbo.ISB_HSStudSched.StudentID, dbo.ISB_HSStudSched.Section, dbo.GbkTermGrade.Letter, dbo.GbkTermGrade.Interval AS Semester
FROM dbo.ISB_HSStudSched INNER JOIN
dbo.GbkTermGrade ON dbo.ISB_HSStudSched.StudentID = dbo.GbkTermGrade.StudentId AND dbo.ISB_HSStudSched.ClassNum = dbo.GbkTermGrade.ClassId
WHERE (dbo.GbkTermGrade.Period = '0') AND dbo.GbkTermGrade.Interval = '1' OR dbo.GbkTermGrade.Interval = '2')

thanks

SQL 2005 SP3
   

- Advertisement -