Six Stars

compare the count between the two tables

Hi,
i have task to compare two views (multiple table combination) or select query with multiple table joined to get count of both views and display this difference in output file,
My output file should display like this
table1 count table2 count Difference
100 500 400
im very new to talend, thanks in advance.
1 REPLY
Seventeen Stars

Re: compare the count between the two tables

What about a query like select count(1) as count_rows from table1 where..... and so on.
Add 2 database input components to your job.
Put your query for the tables into them (one by one).
Click on retrieve schema to get a schema from your query.
Create 2 context variables count1 and count2 from type Integer.
You can memorize the received value into a context variable.
Example:
tMysqlInput_1 --> tJavaRow_1
Code for tJava_1:
context.count1 = input_row.count_rows;

Do the same for your table2.
Now you have 2 filled context variables with counters.
By the way, your topic is in the wrong forum!