用select * from Student where age<=all(select age …………能求出Student表中age 最小值所在的纪录吗?
问题是这样的:
有一张学生信息表Student,里面有一个表示学生年龄的整型字段age,要求不用top 1或min函数,用什么SQL语句能够得到Student表中age 最小值所在的纪录(可能一行,也可能是多行)?
我用下面的语句在MS SQL Server 2000中执行:
select * from Student where age <=all(select age from Student)
运行后,得不到Student表中age 最小值所在的纪录.
请问:怎样改才能得到Student表中age 最小值所在的纪录?
------解决方案-------------------- select *
from Student t1
where not exists (select 1 from Student where age < t1.age)
------解决方案-------------------- select * from Student as A
where not exists(select * from Student where age <A.age)