0

提前致谢:请帮我写一个 sql 查询来查找员工的退休日期出生。

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

4

1 回答 1

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

甲骨文

SELECT
TeacherName,
ADD_YEARS(DateOfBirth, 60) as superannuationDate
FROM Teachers
于 2013-05-15T09:59:01.667 回答