Skip to content
Advertisement

How to join tables when left join does not generate null values for the dates

I have three tables as shown below:

1. kit_test tk

2. employee_badged emp

3. event_badged events

This is my desired Output.

This is the query I have so far:

I am performing this task on RedShift/Dbeaver/PostgreSQL.

Advertisement

Answer

I believe you should FIRST left join the 2 events tables, THEN left join the tested employees with the subquery of results.

something like this (i can’t test it so maybe some correction coul be done on this query)

Maybe you can’t do it, but adding the employee_id in the kit_test table would be improving a lot the table and query design

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement