oracle - SQL Duplication -


context, - have big invoice database. i'm looking duplicates. current situation brings me looking duplication in invoice numbers. i'm using count(*) duplicates , show me ones duplicates whilst ignoring others.

problem - count(*) isn't working, show dummy duplicates i've put in test data, still shows records aren't duplicates.

here's part of code can gist of it:

sql dbselect s2.apar_id, s2.ext_inv_ref john3, s2.ext_inv_ref invno, s2.cur_amount, abs(s2.cur_amount) absamt, s2.trans_date, s2.period, s2.voucher_no, s2.voucher_type,s3.apar_name, s3.apar_gr_id  sql asuhistr s2, asuheader s3  sql ( s2.ext_inv_ref in sql (select s2.ext_inv_ref     sql asuhistr s1     sql , s1.apar_id = '######'     sql group s2.ext_inv_ref     sql having (count(*)> 1)) 

sadly doesn't remove non-duplicate invoice numbers.

any appreciated.

here's full code:

sql dbselect s2.apar_id, s2.ext_inv_ref john3, s2.ext_inv_ref invno, s2.cur_amount, abs(s2.cur_amount) absamt, s2.trans_date, s2.period, s2.voucher_no, s2.voucher_type,s3.apar_name, s3.apar_gr_id  sql asuhistr s2, asuheader s3 sql ( s2.ext_inv_ref in sql (select s2.ext_inv_ref     sql asuhistr s1     sql , s1.apar_id = '######'     sql group s2.ext_inv_ref     sql having (count(*)> 1)) sql , s3.client = s2.client sql , s3.apar_id = s2.apar_id sql , s2.apar_id = '######' sql order s2.apar_id query 

the output gives is: supplier id, supplier name, invoice number, amount, date, etc.. (i'm focusing on invoice number @ moment)

for example, running above code gives me:

supplier id     supplier name       invoice number 123456            abcdefg              999999 568224            rtyuiop              445254 782387            asdasda              999999 734756            werqewq              215423 331231            hdfgsaf              515154 

i want display:

supplier id     supplier name       invoice number 123456            abcdefg              999999 782387            asdasda              999999 

replace:

s2.ext_inv_ref 

with:

s1.ext_inv_ref 

in subquery:

... (select s1.ext_inv_ref asuhistr s1     , s1.apar_id = '######' group s1.ext_inv_ref having (count(*)> 1) .. 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -