我嘗試db-class.org的一些練習videos.There是找到編寫SQL,而無需使用聚合
「誰適用於高校,並選擇 CS爲所有學生的GPA最低的一個問題主要'
使用聚合這是;
select min(gpa) from student,apply where student.sid=apply.sid and major='CS';
結果將是
min
-----
3.4
(1 row)
SID,平均成績表學生而申請表中有場SID,主要
我怎麼能改寫這個不用聚集?
我試圖
select gpa from student,apply where major='CS' and gpa < all(select gpa from student,apply where student.sid=apply.sid and major='CS');
但是這給了我一些14行而不是正確的結果 GPA
-----
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
2.9
(14 rows)
爲什麼會出現這種情況?有人可以幫我嗎?
我會使用一個明確的內部連接,而不是那個隱式連接。 – Corbin 2012-04-03 06:58:52