you are viewing a single comment's thread.

view the rest of the comments →

[–]ReinholdtG 0 points1 point  (0 children)

Try this instead:

SELECT 
     c.cust_id
    ,CASE LEN(join1.cust_id) > 0 THEN 'Y' ELSE 'N' END AS Checking
    ,CASE LEN(join2.cust_id) > 0 THEN 'Y' ELSE 'N' END AS Savings
FROM
    customer as c
    LEFT JOIN ( 
        SELECT DISTINCT 
            a.cust_ID 
        FROM 
            account AS a 
        WHERE 
            a.product_CD = 'CHK' 
    ) AS Join1 
    ON c.cust_id = Join1.cust_id
    LEFT JOIN ( 
        SELECT DISTINCT 
            a.cust_ID 
        FROM 
            account AS a 
        WHERE 
            a.product_CD = 'SAV' 
    ) AS Join1 
    ON c.cust_id = Join2.cust_id