CREATE TABLE staffinfo
(
emp_id INT,
emp_nm VARCHAR(50),
birth_dt DATE,
start_dt DATE,
end_dt DATE
);
INSERT INTO staffinfo (emp_id, emp_nm, birth_dt, start_dt, end_dt)
VALUES (1, 'Ivanov', '1983-01-23', '2013-05-01', '2022-05-20');
INSERT INTO staffinfo (emp_id, emp_nm, birth_dt, start_dt, end_dt)
VALUES (2, 'Petrov', '1985-02-20', '2014-01-23', '2021-06-22');
INSERT INTO staffinfo (emp_id, emp_nm, birth_dt, start_dt, end_dt)
VALUES (3, 'Sidorov', '1980-04-01', '2015-05-05', NULL);
INSERT INTO staffinfo (emp_id, emp_nm, birth_dt, start_dt, end_dt)
VALUES (4, 'Petrov', '2003-01-23', '2024-02-02', NULL);
INSERT INTO staffinfo (emp_id, emp_nm, birth_dt, start_dt, end_dt)
VALUES (5, 'Vetrov', '2001-05-08', '2023-01-24', NULL);
select * from staffinfo;
select emp_id, emp_nm,
case when extract(month from birth_dt) = 1 then birth_dt
when extract(month from start_dt) = 1 then start_dt
end as celebrate_dt
from staffinfo
where (extract(month from birth_dt)= 1 or extract(month from start_dt) = 1)
and end_dt is null;
select max (emp_id) form staffinfo;