我需要从一个数据表里提取一个范围内的数据,基本的语句结构如下
- SQL code
select * from (select column1, ROW_NUMBER() OVER() AS row_num from Table1) as temptable where table.row_num > x and row_num < y
现在我想把column1换成*,就是select所有的列。因为我要select的这个表有上百个字段,我希望对实现是透明的。
- SQL code
select * from (select *,ROW_NUMBER() OVER() AS row_num from Table1) as temptable where table.row_num > x and row_num < y
但是语法这样写是错的,想请教大家应该怎么变形来实现
------解决方案--------------------------------------------------------
select * from (select Table1.*,ROW_NUMBER() OVER() AS row_num from Table1) as temptable where table.row_num > x and row_num < y
------解决方案--------------------------------------------------------
想要达到这要求就需要用子查询了,会降低效率的
select * from Table1 where 主键in (select 主键 from (select 主键, ROW_NUMBER() OVER() AS row_num from Table1) as temptable where temptable.row_num > X and temptable.row_num < Y);