select ROW_NUMBER() over(order by CID) as row_num, * from Classes
执行完上面的sql语句就在表格中添加了名为 row_num 的列,如下图
select * from
(
select ROW_NUMBER() over(order by CID) as row_num, * from Classes
) as t --必须定义子查询后返回的结果集的名称,即t
where t.row_num>=2 and t.row_num<5
下图是最终执行的结果
|