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 行) */
(
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 行)
*/
这个问题其实可以变相地解决,而不是你说的问题。你在前端如何重新获取最新的数据?估计你是使用refresh,或者close然后重新open的方法来不断地保持最新的应用端数据集与后台一致的,你可以在重新获取数据时做查找最小项这个工作。否则,建议你做一个单独的线程,在线程中不断地检索最小项。这个很容易办到。
结果必须还是6条记录,只不过开始时指针位置发生变化,移动到num最小的一行开始!
救命啊!!!
http://community.csdn.net/Expert/topic/4303/4303421.xml?temp=.1166498