退休时间......这个SQL语句怎么写,急急急??????????

hhhglj_hhhglj 2008-01-10 09:11:51
数据库(access)中有出生年月,利用它用SQL语句写出到龄退休(以现在时间为准,)人的列表(男60岁,女55岁)、并且是让退休时间提前三个月的表,
...全文
392 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
不明LZ在说什么
JL99000 2008-01-11
  • 打赏
  • 举报
回复
select * from tablename
where dateadd(month,case when 性别='男' then 60*12 when 性别='女' then 55*12 end)> getdate()
or dateadd(month,case when 性别='男' then 60*12-3 when 性别='女' then 55*12-3 end)> getdate()
hhhglj_hhhglj 2008-01-10
  • 打赏
  • 举报
回复
楼上得到的是所有的人员,但我要的是退休年龄是现在年月日的基础上提前三个月,我的软件中有一个功能是要每3月提示一次本年退休的人员名单,所有要提前通知,主要是这个功能
wzy_love_sly 2008-01-10
  • 打赏
  • 举报
回复
access?sorry
wzy_love_sly 2008-01-10
  • 打赏
  • 举报
回复

declare @tb table (姓名   varchar(10),性别 varchar(64),出生年月 datetime)
insert @tb select '张三','男','1970-01-05'
insert @tb select '李四','女','1982-02-03'
insert @tb select '王五','男','1986-05-02'
insert @tb select '黑八','女','1983-10-01'

select *,dateadd(mm,-3,dateadd(yy,(case when 性别='男' then 60 when 性别='女' then 55 end),出生年月)) as '退休时间'
from @tb


姓名 性别 出生年月 退休时间
张三 男 1970-01-05 00:00:00.000 2029-10-05 00:00:00.000
李四 女 1982-02-03 00:00:00.000 2036-11-03 00:00:00.000
王五 男 1986-05-02 00:00:00.000 2046-02-02 00:00:00.000
黑八 女 1983-10-01 00:00:00.000 2038-07-01 00:00:00.000
-狙击手- 2008-01-10
  • 打赏
  • 举报
回复
mssql :
select *
from table
where datediff(d,birthday,dateadd(mm,3,dateadd(yy,-60,getdate()))>0 and sex = '男'
union all
select *
from table
where datediff(d,birthday,dateadd(mm,3,dateadd(yy,-55,getdate()))>0 and sex = '女'

27,580

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧