我想查前六条吧,就写select top 6 .那我要是查7---12条的记录,怎么写啊?
13---18啥的!谢谢!!!

解决方案 »

  1.   

    如果只是Sql语句的话,我就做下搬运工发个链接上来http://bbs.tech.ccidnet.com/read.php?tid=111362
      

  2.   

    select top 12* from tb where id not in(select top 7 id from tb )
      

  3.   

    你换个思路想象撒你要查 7-12条的,
    你排序下,然后将 前6条 排除,再去前5条不就可以了么查出前 6条的ID,然后条件里面写 ,id不等于这6 个ID的前 5五条数据就是你想要的
      

  4.   

    select top 12* from cn_H_ContactUs where id not in(select top 7 id from cn_H_ContactUs  )
      

  5.   

    http://blog.csdn.net/anchor_jsyc/archive/2007/09/27/1803751.aspx
      

  6.   

    你这样要做什么分页?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)
      

  7.   

    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
      

  8.   

    select top 6 * from cn_H_ContactUs where id not in(select top 7 id from cn_H_ContactUs  )
    应该这样做。
      

  9.   


    up! 如果是Oracle的可以看看Row_num关键字。
      

  10.   

    select * from tb_name where 12>id or id>7
    这种方法也行
      

  11.   

    写错了应该是:select * from tb_name where id>7 and id<12
      

  12.   

    select top 12  * from table where not in (select top 7 * from table) 
      

  13.   


    select * from (select row_number() over (order by Id) as rowId ,* from tb) t
    where t.RowId between 7 and 12
      

  14.   

    给你思路:想TOP 12一下,倒序输出,在TOP 6一下输出,得到的记录就是7~12条的记录了!
      

  15.   

    没有ID的话,是不是只有用not in!!!
      

  16.   

    查询某表中某列7-12条记录:
    SELECT TOP 6 列 FROM 表 WHERE 列 NOT IN(SELECT TOP 6 列 FROM 表)
      

  17.   

    select top 12  * from 表名where not in (select top 7 * from 表名) 
    或者
    select * from  表名 where id>7 and id <12
      

  18.   

    select * from(
    select top 6 * 
    from (select top 12 * from tbname order by col desc ) order by col desc) order by col
      

  19.   

    select top 6 * from table where 主键 not in (select top 6 主键 from table)
    正解!!!!!!!!!!
      

  20.   

    7-12,就是5条,你可以select top 5 * from table where id not in (select top 7 id from table)
      

  21.   

    select top 6* from Employee where ID not in(select top 6 ID from Employee)