提前致谢:请帮我解决一个sql查询,找到一个员工的退休日期,我必须得到所有那些将在不同日期年满60岁的员工,所以我需要得到这些日期从出生之日起。
TeacherName DateOfBirth TeacherAge SupperannuationDate(onwhich teacher going to be 60 yers)
-------------------------------------------------------
S. KHALID SALIM 1958-03-23 00:00:00.000 55
ZUBAIDA BEGUM 1976-08-01 00:00:00.000 36
TANZEEM AKHTAR 1974-09-25 00:00:00.000 38
MARYAM BIBI 1982-08-18 00:00:00.000 30
RABIA TABASSUM 1976-11-10 00:00:00.000 36
这是我的查询,我需要一个名为“AnnunationDate”的第四栏,教师年龄为60岁。
select TeacherName ,DateOfBirth , datediff(mm, DateOfBirth, getdate()) / 12 as TeacherAge from Teachers
------------------------例如,在第一行,它将显示在第四列中 1963-03-23 00:00:00.000 somthing
答案 0 :(得分:0)
SQL服务器
SELECT
TeacherName,
dateadd(year, 60 , DateOfBirth) as superannuationDate
FROM Teachers
Mysql的
SELECT
TeacherName,
DATE_ADD(DateOfBirth, INTERVAL 60 YEAR) as superannuationDate
FROM Teachers
的Oracle
SELECT
TeacherName,
ADD_YEARS(DateOfBirth, 60) as superannuationDate
FROM Teachers