Reputation: 1529
I have a scenario like below and i want to know the oracle query to get the distinct values of first table USER
column like
EXPECTED RESULT
ID | USER
11 | user3
12 | user4
CURRENT TABLES
TABLE A TABLE B
ID | USER ID | USER
11 | user1 11 | user1
11 | user2 11 | user2
11 | user3 12 | user5
12 | user4
12 | user5
Upvotes: 1
Views: 53
Reputation: 44
Another way to approach:
select * from tableA where user not in (select distinct(user) from tableB)
Upvotes: 1
Reputation: 1269623
A simple way is to use minus
:
select id, user
from a
minus
select id, user
from b;
Upvotes: 3