34,594
社区成员
发帖
与我相关
我的任务
分享
select * from 表 where datediff(yy,birthday,getdate()) >20
select * from 表 where datediff(yy,birthday,getdate()) between 20 and 40
union all
select * from 表 where datediff(yy,birthday,getdate()) >40
create table tb(name varchar(50),birthday datetime)
insert into tb select '张','1982-08-10'
insert into tb select '李','1983-08-10'
go
select *,datediff(yy,birthday,getdate()) as 年龄
from tb
where datediff(yy,birthday,getdate()) between 20 and 30