select * from 表 t
where id=(select min(id) from 表 where num=(select min(num) from 表))

解决方案 »

  1.   

    declare @tb table
    (
    id  int,
    name varchar(10),
    num int
    )
    insert @tb
    select 1,'aaa',1 union 
    select 2,'bbb',1 union 
    select 3,'ccc',1 union 
    select 4,'ddd',0 union 
    select 5,'eee',0 union 
    select 6,'fff',0--查询
    select * from @tb t
    where id=(select min(id) from @tb where num=(select min(num) from @tb))--结果
    /*
    id          name       num         
    ----------- ---------- ----------- 
    4           ddd        0(所影响的行数为 1 行)
    */
      

  2.   

    估计你是以SQL server为后台数据库,在前端应用程序中处理的时候遇到的问题。
    这个问题其实可以变相地解决,而不是你说的问题。你在前端如何重新获取最新的数据?估计你是使用refresh,或者close然后重新open的方法来不断地保持最新的应用端数据集与后台一致的,你可以在重新获取数据时做查找最小项这个工作。否则,建议你做一个单独的线程,在线程中不断地检索最小项。这个很容易办到。
      

  3.   

    to  vivianfdlpw() 
    结果必须还是6条记录,只不过开始时指针位置发生变化,移动到num最小的一行开始!
      

  4.   

    借贴主的宝地一用!
    救命啊!!!
    http://community.csdn.net/Expert/topic/4303/4303421.xml?temp=.1166498
      

  5.   

    select top 1 * from 表 order by num
      

  6.   

    楼主。如果按照你的需要。你需要在前台处理数据的。而非sql来解决。