I have a Staff table that includes staff previous promotion and title history.
earliest date in 'startDate' for a staff is the date of the he/she/apache started. lastest date of 'EndDate' for a staff is today. and that title is today's title.
I need to run a script that contains,
Id, Name, StartDate (as day he/she hired), enddate (lastest day of EndDate column) and Title (lastest title)
I tried something but no success..
Sample table as follows:
create table staff
(
PersonId int,
Name varchar(50),
StartDate date,
EndDate date,
Title varchar(50)
);
insert into staff (PersonId,Name,StartDate,EndDate,Title) values
( '2798','Daniel','20200131','20200331','Assistant'),
( '2798','Daniel','20200401','20200630','Senior'),
( '2798','Daniel','20200701','20210331','Manager'),
( '553','Rebecca','20200131','20200430','Senior'),
( '553','Rebecca','20200501','20210331','Manager')
;
select * from staff;