Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
japhias
Contributor II
Contributor II

Compare two tables from different dates

Dear all,

as a first step I want to compare to exports from different dates, one initial export and one latest. As a secound step it would be nice, if the user is able to compare exports from different dates, but first lets focus on the first step:

I have two tables (always with the same columns, with changing  number of rows) exported on 2 different dates (initial and latest).  I did  a Concatenate between this two tables. I have key that will be the same in the table versions. 

I want to visualize:

- what records/rows were deleted from initial to latest version
- what records were created in the latest version
- what attributes have changed from initial to latest version

How can I do that?

Labels (1)
3 Replies
Marcoimp
Partner - Creator III
Partner - Creator III

Hi Japhias,
The question is not so clear (for me).

Do you need to count id/rows or to know wich id/rows are in first, last condition?

Can you provide an example of resulting table?

M.Imperiale
japhias
Contributor II
Contributor II
Author

Hi,

thank you for your response. I try to explain a little bit more with an example:

japhias_0-1595934622551.png

 

Marcoimp
Partner - Creator III
Partner - Creator III

Ok!
I think you can do something like this:

init_tab:
load ID, Date as Date1, Weight as Weight1 From InitialTable;

outer join
load ID, Date as Date2, Weight as Weight2 from LatestTable;

FinalTab:
Load
   ID,
   if(isnull(Weight2),'deleted', if(isnull(Weight1),'new','')) as Status,
   if(Weight1<>Weight2,'Changed','')) as WeightStatus
Resident init_tab;

drop table init_tab;

 

Maybe you have to add some "IF" for Date1 and Date2 so you can see what value is the most recent... or something like this... Hope can help!

 

 

M.Imperiale