麻烦问一下 
sql查询 
能不是实现 隔5查询 
查询第一条记录 然后查询地5条记录,在查询第10条记录 以此类推

解决方案 »

  1.   

    select * from tb where id%5=0
    union all
    select * from tb where id = 1
    order by id
      

  2.   

    应该是按照1,5,9取吧?
    就是取余为1 行号 % 4 = 1做法,先求行号。select *
    from 
    (SELECT ROW_NUMBER() OVER (ORDER BY [主键] ASC) AS ROWID,*
      FROM 表
    as  a
    where ROWID % 4 = 1

      

  3.   

    select *
    from 
    (SELECT ROW_NUMBER() OVER (ORDER BY [主键] ASC) AS ROWID,*
      FROM 表
    )as  a
    where ROWID % 4 = 1
      

  4.   

    select * from products where productid in
      (select productid from products where productid%5=0) 
        order by productid asc
    这是sql server 2000中northwind数据库中的products