你这样要做什么分页?select top 6 max(id), * from table 记录num = max(id)select top 6 max(id), * from table where id > num 记录num = max(id)select top 6 max(id), * from table where id > num 记录num = max(id)
with t_rowtable as(select row_number() over(order by z.ID) as row_number,z.ID from table as z) select * from t_rowtable where row_number>='" + start + "' and row_number < ='" + end + "' order by ID只能用在SQL2005
select top 6 * from cn_H_ContactUs where id not in(select top 7 id from cn_H_ContactUs ) 应该这样做。
up! 如果是Oracle的可以看看Row_num关键字。
select * from tb_name where 12>id or id>7 这种方法也行
写错了应该是:select * from tb_name where id>7 and id<12
select top 12 * from table where not in (select top 7 * from table)
select * from (select row_number() over (order by Id) as rowId ,* from tb) t where t.RowId between 7 and 12
给你思路:想TOP 12一下,倒序输出,在TOP 6一下输出,得到的记录就是7~12条的记录了!
没有ID的话,是不是只有用not in!!!
查询某表中某列7-12条记录: SELECT TOP 6 列 FROM 表 WHERE 列 NOT IN(SELECT TOP 6 列 FROM 表)
select top 12 * from 表名where not in (select top 7 * from 表名) 或者 select * from 表名 where id>7 and id <12
select * from( select top 6 * from (select top 12 * from tbname order by col desc ) order by col desc) order by col
select top 6 * from table where 主键 not in (select top 6 主键 from table) 正解!!!!!!!!!!
7-12,就是5条,你可以select top 5 * from table where id not in (select top 7 id from table)
select top 6* from Employee where ID not in(select top 6 ID from Employee)
你排序下,然后将 前6条 排除,再去前5条不就可以了么查出前 6条的ID,然后条件里面写 ,id不等于这6 个ID的前 5五条数据就是你想要的
记录num = max(id)select top 6 max(id), * from table where id > num
记录num = max(id)select top 6 max(id), * from table where id > num
记录num = max(id)
应该这样做。
up! 如果是Oracle的可以看看Row_num关键字。
这种方法也行
select * from (select row_number() over (order by Id) as rowId ,* from tb) t
where t.RowId between 7 and 12
SELECT TOP 6 列 FROM 表 WHERE 列 NOT IN(SELECT TOP 6 列 FROM 表)
或者
select * from 表名 where id>7 and id <12
select top 6 *
from (select top 12 * from tbname order by col desc ) order by col desc) order by col
正解!!!!!!!!!!