I created the following snippet to let you know the issue I have
The query is used to get all the rows where I have the most recent day, study_id and status of a candidate from that table.
As you see from the example I'm getting only 2 rows but I should have more also including the rows having site_id === null.
I should have included also the row
('2020-01-02 00:00:00+00', 'TBX1', NULL, 'INCOMPLETE', 120, 100)
The final result I'm expecting
| study_id | site_id | status | day | day | study_id | site_id | status | total | current |
|---|---|---|---|---|---|---|---|---|---|
| TBX1 | SWE-1 | INCOMPLETE | 2020-01-02 00:00:00+00 | 2020-01-02 00:00:00+00 | TBX1 | SWE-1 | INCOMPLETE | 37 | 31 |
| TBX1 | SWE-2 | INCOMPLETE | 2020-01-02 00:00:00+00 | 2020-01-02 00:00:00+00 | TBX1 | SWE-2 | INCOMPLETE | 43 | 41 |
| TBX1 | null | INCOMPLETE | 2020-01-02 00:00:00+00 | 2020-01-02 00:00:00+00 | TBX1 | null | INCOMPLETE | 120 | 100 |
So, therefore, is included the row also wth site_id null