How to write Java code to read 2 queries from excel sheet and compare their DB records?

94 Views Asked by At

Please help with DB comparsion code in java. I have two queries to execute in same database and compare their records against each other.

1

There are 1 best solutions below

0
On

You might want to run both queries and do the comparison in DB2. There are variuos ways to do a full comparision of two data sets in SQL. This is one idea

WITH Q1 AS ( put your first query here  )
,    Q2 AS ( put your second query here )
SELECT 'In Q1 not Q2', Q.*
FROM  (SELECT * FROM Q1 MINUS SELECT * FROM Q2) Q
UNION ALL
SELECT 'In Q2 not Q1', Q.*
FROM  (SELECT * FROM Q2 MINUS SELECT * FROM Q1) Q