select top N时怎么指定按某个字段进行排序??
换句话说select top 3 * form tb 是按哪个字段排出来的top3?
最为奇怪的是,我的这条语句竟然会返回2条记录,请问有是什么问题引起的?
select top 2 [name] from UserInfo
where [name] not in
(select top 1 [name] from UserInfo order by cn DESC )
order by cn DESC
------解决方案-------------------- "select top 3 * form tb "这也行,高手!
------解决方案--------------------SELECT TOP 3 * FROM yTB ORDER BY yCOL
------解决方案--------------------select top 2 [name] from UserInfo
where [name] not in
(select top 1 [name] from UserInfo order by cn DESC )
order by cn DESC
===============================================================
检索出两条没错啊,你仔细看看吧。估计你的头有些晕!
不过检索出两条数据是没错的。
------解决方案----------------------try
select ID=identity(int,1,1),[name] into #T
from UserInfo
order by cn DESC
select [name] from #T where ID=2