Solved

Find records in one table that doesnt exist in another - Crystal Reports 11

Posted on 2011-02-27
3
652 Views
Last Modified: 2012-06-27
Hello experts,

I have two tables that have similar demographic info, but are without any primary keys or identifiers.  I have a need to find all of the records in the person table, that do not exist on the subscriber table.  They have similar columns, but are named a little different - same datatypes though.  Here is my script, and I'm having trouble with the syntax, as I am not sure which column to join on.  I need to make sure that lastname, firstname, and date_of_birth are the three pieces of data that dont match in the other table:

select n.subscriber_firstname, n.subscriber_lastname, n.subscriber_date_of_birth, n.SUBSCRIBER_SSN
from NGC_SUBSCRIBER n
left join person p
on n.SUBSCRIBER_SSN = p.ssn
where n.SUBSCRIBER_LASTNAME <> p.last_name
and n.SUBSCRIBER_FIRSTNAME <> p.first_name
and n.SUBSCRIBER_DATE_OF_BIRTH <> p.date_of_birth
and p.last_name is null

Thoughts?

Thanks!
0
Comment
Question by:robthomas09
3 Comments
 
LVL 9

Accepted Solution

by:
rg20 earned 250 total points
ID: 34993064
You say you want the data from the persons table that doen't exist in the subscriber table
but your query

select n.subscriber_firstname, n.subscriber_lastname, n.subscriber_date_of_birth, n.SUBSCRIBER_SSN
from NGC_SUBSCRIBER n
left join person p
on n.SUBSCRIBER_SSN = p.ssn
where n.SUBSCRIBER_LASTNAME <> p.last_name
and n.SUBSCRIBER_FIRSTNAME <> p.first_name
and n.SUBSCRIBER_DATE_OF_BIRTH <> p.date_of_birth
and p.last_name is null


is returning the subscriber data, should it not be the p.last_name, p.first_name, p.date_of_birth?
0
 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 250 total points
ID: 34993080
select p.first_name
, p.last_name
, p.date_of_birth
, p.ssn
from person p
where p.ssn not in (select n.SUBSCRIBER_SSN from NGC_SUBSCRIBER n)
0
 

Author Comment

by:robthomas09
ID: 34993088
Thanks for the replies -rg20 - I'm looking for the values in the subscriber table that arent in the person table. I posted that incorrectly up top sorry about that.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question