Remove Duplicates from LEFT OUTER JOIN

Posted by Kaushik Gopal on Stack Overflow See other posts from Stack Overflow or by Kaushik Gopal
Published on 2010-03-28T14:54:16Z Indexed on 2010/03/28 15:03 UTC
Read the original article Hit count: 542

Filed under:
|
|
|
|

Hey folk my question is quite similar to http://stackoverflow.com/questions/757957/restricting-a-left-join

I have a variation in that request though and the comment didn't allow too many characters hence posting as a new question. I hope this doesn't go against the posting rules/etiquette.

Assuming i have a table SHOP and another table LOCATION. Location is a sort of child table of table SHOP, that has two columns of interest, one is a Division Key (calling it just KEY) and a "SHOP" number. This matches to the Number "NO" in table SHOP.

I tried this left outer join:

SELECT S.NO, L.KEY FROM SHOP S LEFT OUTER JOIN LOCATN L ON S.NO = L.SHOP

But i'm getting a lot of duplicates since there are many locations that belong to a single shop. I want to eliminate them and just get a list of "shop, key" entries without duplicates. any ideas how?

(edit: ORACLE 10g Database)

© Stack Overflow or respective owner

Related posts about sql

Related posts about left-join