https://www.gov.cn/yaowen/liebiao/202409/content_6974294.htm
基于这个决定,我们可以编写一个SQL查询语句,根据自己的性别和出生日期计算最新的法定退休年龄:
-- PostgreSQL实现
WITH person_info(category, birthday) AS ( -- 输入个人信息
SELECT '男职工', '1985-01-01'::date
),
original_retirement AS ( -- 改革前退休时间
SELECT CASE category
WHEN '男职工' THEN birthday + INTERVAL '60 year'
WHEN '女干部' THEN birthday + INTERVAL '55 year'
WHEN '女员工' THEN birthday + INTERVAL '50 year'
END retirement_age
FROM person_info
),
delay_month(n) AS ( -- 延迟月数
SELECT CASE category
WHEN '男职工' THEN LEAST(36, 1+(EXTRACT(year FROM age(birthday,'1965-01-01'::date))*12 + EXTRACT(month FROM age(birthday,'1965-01-01'::date)))::int/4)
WHEN '女干部' THEN LEAST(36, 1+(EXTRACT(year FROM age(birthday,'1970-01-01'::date))*12 + EXTRACT(month FROM age(birthday,'1970-01-01'::date)))::int/4)
WHEN '女员工' THEN LEAST(50, 1+(EXTRACT(year FROM age(birthday,'1975-01-01'::date))*12 + EXTRACT(month FROM age(birthday,'1975-01-01'::date)))::int/2)
END
FROM person_info
)
SELECT category "员工类型",
birthday "出生日期",
retirement_age "原始退休时间",
n "延迟月数",
retirement_age + make_interval(0, n) AS "改革后退休时间"
FROM person_info, original_retirement, delay_month;
员工类型|出生日期 |原始退休时间 |延迟月数|改革后退休时间 |
-------+----------+-----------------------+------+-----------------------+
男职工 |1985-01-01|2045-01-01 00:00:00.000| 36|2048-01-01 00:00:00.000|
以上查询应该说非常简单易懂了,person_info 代表了职工的信息;original_retirement 是改革之前的退休时间;delay_month 是改革后延迟的月数,如果不是使用 PostgreSQL,需要调整一下函数;最后得到了改革之后的退休时间。
所以,我们只要在查询的最开始输入自己的工种和出生日期,就可以得到退休时间了。
你还能再为国家奉献几年呢?