sql - Eliminate common rows from two tables - MS Access -


i have 2 tables have same structure:

'ncc code' - integer 'vendor' - short text 'profit center' - short text 'business franchise' - short text 'business division' - short text 'spend' - float 'savings' - float 

these tables contain different sets of data, coming 2 different sources. there rows identical in both, different. difference not same rows, it's not in same column (ex: records can differ 'business franchise' , other columns identical, others 'savings' , otherb more 1 column).

there no unique value or key in each of tables come generated dwh system.

as far software tools go have access ms access 2013 , ms excel 2013.

i need find way identify , extract rows 1 table, not found in other. give me advice on how it? i've tried various methods no avail.

thank you!

using left join (only displays in not b switch table order , union results both)

select *  left join b  on a.col1=b.col1 , a.col2=b.col2 , a.col3=b.col3 , a.col4=b.col4... b.col1 null union select *  b left join  on a.col1=b.col1 , a.col2=b.col2 , a.col3=b.col3 , a.col4=b.col4... b.col1 null 

using union , aggregate : display records either table not in other (a not in b , b not in a) union doesn't distinct out duplicates (union distinct) exclude records having more 1 occurrence. assumes each table doesn't have duplicates in start with. if make distinct table before union all.

and aggregating

select <all columns less src), max(src) srctable, cnt(1) (select a.*, 'a' src           union       select b.*, 'b' src      b ) c group <all columns less src> having count(1) < 2 

i added src knew table record came from. max(src) works because record exists in 1 place. , exclude in both.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -