JOIN with Select and TOP not returning data to results

JOIN with Select and TOP not returning data to results


hi

when I add TOP to yellow it does not return cl."Id", cl."Date",cl."Outcome", cl."Membership" from the join. Remove it and they appear.

The TOP and the ON seem to work as in the number of rows returned. 

Doing the classic join log table and return only the last log entry. Very different to MS SQL!


 SELECT
ol."Id",
ol."Membership",
m."Membership Status",
ol."Date" as "Overturned Date",
date_diff(cl.Date, ol."Date") as "Saved Days",
ol."Outcome",
u."Full Name" as Advisor,
cl."Id" as cancelled_log_id,
cl."Date" as cancelled_log_date,
cl."Outcome" as cancelled_log_outcome,
cl."Membership" as cancelled_log_membership
FROM  "Membership Logs (Zoho CRM)" AS  ol
LEFT JOIN "Memberships (Zoho CRM)" AS  m ON ol."Membership"  = m."Id" 
LEFT JOIN "Users (Zoho CRM)" AS  u ON ol."Advisor"  = u."Id" 
LEFT JOIN( SELECT TOP 1
"Id",
"Date",
"Outcome",
"Membership"
FROM  "Membership Logs (Zoho CRM)" 
WHERE Outcome  = 'Cancelled'
ORDER BY "Date" DESC 
) AS  cl ON cl."Membership"  = ol."Membership"
AND cl."Date"  >= ol."Date"  
WHERE ol."Activity"  = 'Cancellation'
 AND ol."Outcome"  like 'Overturn%'
 AND m."Membership Status"  = 'Cancelled'