我用的是sql server数据库.想做一个根据条件排序的分页,就是说不按ID来排序,用其他字段来排序,想问一下这个SQL语句该怎么写

解决方案 »

  1.   

    select * from table where id=? and id not in(select top 5 id from table where id=?)
    order by id descwhere条件,排序条件可以自己变
      

  2.   

    可能你还没有我的意思,比如一个表中有两个字段,一个是ID号,一个字段名为Num,类型为int;现在我要把这个表里的记录都取出来,每页10行,并且是按Num字段的大小进行降序排序
      

  3.   

    select * from [table]
    order by Num desc
      

  4.   

    假设当前页为第page_current页,每页显示page_size条
    当前页显示记录的sql语句为:sql="select top '"+page_size"' * from table where id=? and id not in(select top'"+(page_current-1)*page_size+"'id from table where id=?) order by id desc";
      

  5.   

    假设当前页为第page_current页,每页显示page_size条
    当前页显示记录的sql语句为:sql="select top '"+page_size"' * from table where id=? and id not in(select top'"+(page_current-1)*page_size+"'id from table where id=?) order by id desc";
      

  6.   

    select top 10 * from table where Num not in(select top 0 Num from table)
    order by Num desc
      

  7.   

    参考:http://community.csdn.net/Expert/topic/4270/4270153.xml?temp=.3592493
    演示:http://shop.echai.net/erp,用户名和密码都是:admin,其中修改用户或订单后,都可以刷新父页面