Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

How to rewrite this correlated subquery using joins

I have a correlates subquery. The query selects all bank customers with more than one bank account.

SELECT c.cust_id,c.cust_type_cd,c.city FROM customer c
WHERE 2 = (SELECT COUNT(*)
FROM account a WHERE a.cust_id = c.cust_id)

So my question is, how can I rewrite this query, so that is uses only joins?
ASKER CERTIFIED SOLUTION
Avatar of Thomasian
Thomasian
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jamieo1,

There won't be any duplicates after using GROUP BY...