SUB QUERY SLECT FIRST RECORD ONLY - Ingres Database

22 Views Asked by At

I am using below query in ingres.I believe FETCH FIRST 1 ROWS ONLY is not supported in subquery in Ingres .How i can acheive the same funcitolaity in Ingres?

 SELECT 
DISTINCT tp.p_shared_with_email,
COALESCE(c.given_names || ' ' || c.surname, '') AS userName,
tp.start_date AS startDate,
tp.end_date AS endDate,
tp.party_id,
CASE 
    WHEN (tp.start_date <= CURRENT_DATE AND (tp.end_date IS NULL OR tp.end_date > CURRENT_DATE)) THEN 1
    WHEN (tp.start_date <= CURRENT_DATE AND tp.end_date IS NULL AND tp.Status = 1) THEN 1
    ELSE 0
END AS Status,
tp.shared_with_customerid
FROM 
party_project tp
LEFT JOIN client c ON tp.p_shared_with_email = c.email_address 
AND c.client = (SELECT b.client FROM client b WHERE b.email_address = 
tp.p_shared_with_email FETCH FIRST 1 ROWS ONLY)
WHERE 
tp.w_request = 'ABC';
0

There are 0 best solutions below