Reputation: 8247
I have two tables in Oracle, customer_details and account_details.
customer_details
cus_id rating
ABC12 RT
CED34
FRTG4 RT
RET43
ERT45 VF
account_details
cus_id account_type scas_code
ABC12 SA 0011
DEF34 CA 009
CED34 SA 0011
RET43 FD 008
ERT45 SA 0011
I want DISTINCT
scas_code from table account_details
where rating
should be null from customer_details
table. My desired result of the query is following
scas_code
0011
008
How can I write this query?
Upvotes: 0
Views: 34
Reputation: 520898
You could use exists logic here:
SELECT DISTINCT scas_code
FROM account_details ad
WHERE EXISTS (SELECT 1 FROM customer_details cd
WHERE cd.cus_id = ad.cus_id AND cd.rating IS NULL);
Upvotes: 1
Reputation: 37473
You can try the below -
select distinct scas_code
from account_details a inner join customer_details b on a.cust_id=b.cust_id
where rating is null
Upvotes: 1