jeudi 28 avril 2016

Compare Tables A and B and bring out Error of same UniqueCode but different Credit value.

TABLE A

SN UniqueCode Debit Credit 1 1253 722 2 Auto 1500 3 Dep 4300
4 Ret 1200 5 1257 14 6 1254 2982 7 1255 722 8 Auto 498 9 DC 120 10 1256 672 11 Dep 7300
12 DC 135

TABLE B

SN UniqueCode Debit Credit 1 1257 722 2 Auto 1500 3 Dep 4300
4 Ret 1200 5 DC 140 6 1254 2982 7 1255 722 8 Auto 498 9 DC 120 10 1256 672 11 Dep 7300
12 DC 135

Please the two tables A and B have same Uniquecode 1256 but different Credit of 672 and 675 respectively. I need to bring out the rows in the tables.This have been identified in a bank application as an Error. The difference in the Credit Values is the Error (675-672).

This is one of queries that failed: String d = "SELECT b.UniqueCode, b.Credit As 'Error Alert' FROM CashImport b WHERE NOT EXISTS " + "(SELECT a.Credit FROM BankImport a WHERE a.Credit = b.Credit and a.UniqueCode = b.UniqueCode)group" + " by b.Credit having count(UniqueCode)=1";//Uncredited Cheques with error var1

Thank you and best regards.

Aucun commentaire:

Enregistrer un commentaire