34,593
社区成员
发帖
与我相关
我的任务
分享
select *
from t_student
where sage>(select avg(sage) from t_student)
order by sage desc
if object_id('[tb]') is not null drop table [tb]
go
create table tb (age int)
insert into tb
select '25' union all
select '30' union all
select '30' union all
select '54' union all
select '55'
go
select * from tb where age >(select avg(age) from tb)
go
---取年龄大于平均年龄的
--age
--54
--55
select * from tb a where exists (
select 1 from (select age from tb group by age having count(age)=2)
b where a.age=b.age)
---取年龄相同年龄
--age
--30
--30