Anda hanya perlu memindahkan WHERE
klausa ke kueri dalam.
SELECT TeacherID, UniversityID, RowNum FROM
(
SELECT a.TeacherID, a.UniversityID, ROW_NUMBER() OVER
(ORDER BY a.TeacherID) AS RowNum FROM SelectAll a
LEFT JOIN mp_Ratings r
ON a.TeacherID = r.TeacherID
WHERE UniversityID = 2
GROUP BY a.TeacherID, a.UniversityID
) as TeacherInfo WHERE RowNum BETWEEN 10 AND 50;
Anda tidak dapat mengakses RowNum
alias di versi luar kueri karena alias belum ada. SELECT
diuraikan kedua terakhir, sebelum ORDER BY
. WHERE
diproses sebelum SELECT
.