• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1139
  • Last Modified:

Compare two columns in different tables and extract difference between them

I am using MS-SQL Query Analyser.

I have two tables ("A" & "B") that both have a column named "X".  Both columns contain the same type of information.  There are some differences betwen the contents of the 2 columns.

In particular, Table A col X contains a list of approx 100000 distinct numbers.  Table B col X contains approx 1 million numbers (not distinct).

I need to find out which numbers in table B col X do not exist in table A col X.  Help please!!!!!!  Thank you!
0
thedaveg155
Asked:
thedaveg155
  • 2
1 Solution
 
Helena Markováprogrammer-analystCommented:
This works in Oracle, I think you can change it if neccessary to  MS-SQL:

Select X from B
MINUS
Select X from A;
0
 
thedaveg155Author Commented:
Just figured it myself.  Thanks for the comment but it didn't work for me.

Either:
SELECT DISTINCT * FROM A
WHERE X Not In (SELECT DISTINCT X FROM B)
Or:
SELECT A.* FROM A
LEFT JOIN B on A.X = B.X
WHERE B.X Is Null
0
 
Helena Markováprogrammer-analystCommented:
You can ask 0-point question in a Community Support for refunding points :)
0
 
mlmccCommented:
This question has been answered by the asker.

mlmcc
DB Reporting Tools PE
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now