我是SQL Server的新手。請幫我找兩門課程的成績之間的關係。如何看課程成績之間的關係?
我想找到哪個學生在'計算機編程'中獲得'A'成績,並且在計算機入門課上也有'A'成績。
這是數據看起來的樣子:
RollNum | CGPA | Status | Name | Grade
410 | 2.6 | Completed | Introduction to Computer Science | A
410 | 2.6 | Completed | Computer Programming | A-
422 | 3.2 | Completed | Introduction to Computer Science | A
422 | 3.2 | Completed | Computer Programming | A
223 | 3.52 | Completed | Introduction to Computer Science | A
223 | 3.52 | Completed | Computer Programming | A
521 | 1.2 | Completed | Introduction to Computer Science | B+
521 | 1.2 | Completed | Computer Programming | A-
....
....
這是我寫的查詢:
SELECT [RollNum],[CGPA],[Status],[Name],[FinalGrade]
FROM db
where Name ='Introduction to Computer Science' and FinalGrade='A'
and (Name='Computer Programming' and FinalGrade= 'A')
請幫助我,在此先感謝。
如何爲您的當前查詢不工作?另外,你應該閱讀數據庫規範化。我發現您的數據構建方式存在一些問題。 –
+1 - 只是爲了擺脫-1,因爲即使這個問題是非常具體的(本地)它仍然很好的結構和足夠的細節 – whytheq