3表是有,一個是學生,第二個是主體和第三個是馬克表。如何查詢以獲得此結果?
student table:
student_id student_name
subject table:
subject_id subject_name
marks table:
student_id subject_id marks
我寫此查詢:
select student_id, subject_id, marks, RANK() over (partition by subject_id order by marks desc rank
from marks order by student_id, subject_id;
它給正確的結果,但我想到位student_id數據和subject_id的student_name和SUBJECT_NAME。
如何加入這些表? 謝謝。
你編寫使用'排名在Partition'查詢,但你不理解一個簡單的'加入'概念...? – Siyual 2014-09-24 13:15:35