Difficult SQL query, is this possible?
First Table
--FN---LN----Reasons
John | Doe | 6 |
Jane | Doe | 2 |
-----------------
That's the end of the first table.
Second Table
---Reason----Reason Detail-----
2 | Invalid SSN
4 | Invalid Date Of Birth
--------------------------------------
That's the end of the second table. (*Note, there is NO value of '6' in the second table)
I need a SQL query that returns the following:
------------------------------------------
John | Doe | 4 | Invalid SSN
John | Doe | 2 | Invalid Date of Birth
Jane | Doe | 2 | Invalid Date of Birth
------------------------------------------
John Doe has fallen out of our system for both an invalid SSN and an Invalid DOB, how can I split that information up in a SQL query?
1) These tables were designed to have this type of logic used against them, so there is only one unique combination to give the value '6' in the reasons column.
2) Yes, I do know this isn't the best way to do it... The only reason I can think of was due to how large the first table will get. And no, changing the way we do it now isn't a possibility.
3) The second table is fairly large, about 20-30 reasons, so creating every possible combination to populate a third table is daunting.
Everyone in my office is stumped... can anyone here help?



