Staff changed their profiles as shown in this table:
The result of latest information should be like this:
I applied the technique from this question for embedded Firebird of LibreOffice Base, the query has error.
1 Answer 1
SELECT DISTINCT StaffCode,
FIRST_VALUE(FirstName)
OVER (PARTITION BY StaffCode
ORDER BY CASE WHEN FirstName IS NOT NULL
THEN EffectiveDate
END DESC) FirstName,
FIRST_VALUE(LastName)
OVER (PARTITION BY StaffCode
ORDER BY CASE WHEN LastName IS NOT NULL
THEN EffectiveDate
END DESC) LastName,
FIRST_VALUE(MarriageStatus)
OVER (PARTITION BY StaffCode
ORDER BY CASE WHEN MarriageStatus IS NOT NULL
THEN EffectiveDate
END DESC) MarriageStatus
FROM SourceTable;
answered Nov 12, 2020 at 10:32
Explore related questions
See similar questions with these tags.
lang-sql