select num
from test a
where not exists(select 1 from test where num<a.num)
from test a
where not exists(select 1 from test where num<a.num)
解决方案 »
- 求解数据库sql2005问题
- 为什么这两个表达式都用Ceiling函数,结果不一样
- 请大家帮我写一写这条SQL查询语句
- 求一SQL查询语句?
- 新建了一个函数,将交叉表中的数据读出!老是错误!请高手看看!
- 关于SQLServer作业调度(实现定时执行的程序)的问题!请帮忙!
- SQL SERVER是按主键排序的吗?怎样才能让它按identity类型的键排序?
- 简单问题 有分散 (刚才写的有问题对不起)
- 分组汇总实现,请大家帮忙
- 数据库中包括哪三种数据集?哪一种数据集的数据能够立即更新?
- 链接远程数据库出现错误;'MSDASQL' IDBInitialize::Initialize returned 0x80040e4d: 验证失败。
- 怎样可以批量更新
select num from test a
declare @min int,
@temp int
set @temp =0
open cursor_c
fetch cursor_c into @min
while @@fetch_status=0
begin
if @min<@temp
set @temp=@min
fetch cursor_c into @min
end
close cursor_c
deallocate cursor_c
print @temp
select num from test a
declare @min int,
@temp int
set @temp =0
open cursor_c
fetch cursor_c into @min
while @@fetch_status=0
begin
if @min<@temp
set @temp=@min
fetch cursor_c into @min
end
close cursor_c
deallocate cursor_c
print @temp
for
select iid from test3
open cur_tab
declare @idvalue int
declare @i int
fetch next from cur_tab into @idvalue
set @i=@idvalue
while @@fetch_status=0
begin
if @i<@idvalue set @i=@idvalue
fetch next from cur_tab into @idvalue
end
print @i
SELECT * from test
declare @maxrow int
set @maxrow=@@rowcount
declare @num int
set @num=(select top 1 num from test)
declare @i int
set @i=2
while @i<=@maxrow
Begin
if exists (select * from test where num<@num)
set @num=(select top 1 num from test where num<@num)
set @i=@i+1
End
select @num
的答案很正确.select num
from test a
where not exists(select 1 from test where num<a.num)另外还有select num
from test a
where a.num > all (select num from test where num <> a.num)这个的效率没有上面的好。 数据量大时效率差异越明显.