0

Staff changed their profiles as shown in this table:

enter image description here

The result of latest information should be like this:

enter image description here

I applied the technique from this question for embedded Firebird of LibreOffice Base, the query has error.

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Nov 12, 2020 at 10:09
0

1 Answer 1

2
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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.