select * from tb where id%5=0 union all select * from tb where id = 1 order by id
应该是按照1,5,9取吧? 就是取余为1 行号 % 4 = 1做法,先求行号。select * from (SELECT ROW_NUMBER() OVER (ORDER BY [主键] ASC) AS ROWID,* FROM 表 as a where ROWID % 4 = 1 )
select * from (SELECT ROW_NUMBER() OVER (ORDER BY [主键] ASC) AS ROWID,* FROM 表 )as a where ROWID % 4 = 1
select * from products where productid in (select productid from products where productid%5=0) order by productid asc 这是sql server 2000中northwind数据库中的products
union all
select * from tb where id = 1
order by id
就是取余为1 行号 % 4 = 1做法,先求行号。select *
from
(SELECT ROW_NUMBER() OVER (ORDER BY [主键] ASC) AS ROWID,*
FROM 表
as a
where ROWID % 4 = 1
)
from
(SELECT ROW_NUMBER() OVER (ORDER BY [主键] ASC) AS ROWID,*
FROM 表
)as a
where ROWID % 4 = 1
(select productid from products where productid%5=0)
order by productid asc
这是sql server 2000中northwind数据库中的products