我想从偏移的视图中选择数据以进行分页,并按注册日期排序。
我在下面有代码示例。
SELECT student_id,student_name
FROM student
WHERE student_id IN(
SELECT TOP 15 student_id
FROM student(
SELECT ROW_NUMBER() OVER (ORDER BY register_date_time DESC) AS rowNo,student_id
FROM student
) tb_pagination WHERE rowNo > 30
)
我的代码运行正常,但从服务器到客户端请求的响应速度太慢。
有谁能告诉我如何让它变得更好?
答案 0 :(得分:0)
试试这个:
SELECT student_id,student_name
FROM (
SELECT ROW_NUMBER() over (ORDER BY register_date_time DESC) AS rowNo,
student_id,
student_name
FROM student
) tb_pagination
WHERE rowNo > 30
AND rowNo < 45