-2

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

  • Please [edit] the question to include a [mre], sample data, and to clarify what type of comparison you want to perform. – Jason Aller Jul 17 '19 at 19:04

1 Answers1

0

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
Paul Vernon
  • 3,818
  • 1
  • 10
  • 23