compare the count between the two tables

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.
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!

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog