0

I have a table with sample1 and sample2 Columns. Some of the sample2 values exist in sample 1. Now I want to extract a table where sample2 value is NOT available in sample1. Please see the tables below for clarification. Thanks.

enter image description here

1
  • 1
    It looks like your sample data is inconsistent with your description. E & I are in your sample 1 and sample 2 but still show on the output table Commented Feb 14, 2020 at 6:39

2 Answers 2

1

You can use NOT EXISTS :

SELECT t.*
FROM table t
WHERE NOT EXISTS (SELECT 1 FROM table t1 WHERE t1.sample1 = t.sample2);
Sign up to request clarification or add additional context in comments.

1 Comment

@mumid . . . NOT EXISTS is better with a subquery because it handles NULL values intuitively.
0

You basically said the answer in you question. Make sure Sample2 is NOT IN Sample1


SELECT *
FROM Table
WHERE Sample2 NOT IN (SELECT Sample1 From Table)

2 Comments

You are welcome. You have been faster than me and here is a oracle fiddle if you want to attach it: dbfiddle.uk/… cheers
Trying to practice. Answering questions is how I learned my first language so moving onto SQL. I don't know how to use fiddle but will look at what you shared! Super useful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.