Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Table Join Help

Author  Topic 

Ratz03
Starting Member

27 Posts

Posted - 2015-02-01 : 15:30:32
I am doing a reconciliation report for records from 2 systems A and B. I am storing all recording in from System A and System B in a single table.

eg
Table Rec
Source Name Number Age
A XYZ 12 33
A ABC 34 6
A uyg 87 77
B XYZ 12 33
B ABC 34 6
B iii 22 7

and write a query like
Select t1.Source,
t2.source,
t1.Name, t2.name,
t1.number, t2.number,
t1.age, t2 age
from rec t1 left join rec t2
on t1.name = t2.name
where t1.source = A and t2.source = B

This returns me all records in source A and B. However I need all records from table rec, that is records in A and not in B and records in B and not in A.

Require help in how to retrieve it from table rec. I am able to do it from 2 individual tables for A and B but requirenent is to do it from table rec.

Thanks for your suggestions in advance.


sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2015-02-01 : 18:52:38
Hi,
Can you please post test data in terms of table format with test result to help you out.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2015-02-02 : 01:11:12
You may need to use FULL OUTER JOIN

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -