SELECT *
FROM scores
ORDER BY score DESC, student_id ASC;
score DESC 排序(成績高低)。student_id ASC 排序(學號升序)。寫兩個 ORDER BY 子句:
-- 錯誤:語法錯誤,僅允許一個 ORDER BY 子句
ORDER BY score DESC
ORDER BY student_id ASC
CREATE INDEX idx_score_stu ON scores(score DESC, student_id ASC);OFFSET ... FETCH (SQL 2012+)。