With the following query:
SELECT ADSTAT, ADASNO, ORDERNO FROM BLUEWATER ORDER BY ADASNO;
I can get the following:
ADSTAT ADASNO ORDERNO
40 ASN123 40303020
40 ASN123 40303020
30 ASN124 40303021
30 ASN124 40303021
30 ASN125 40303021
I am looking for a query that will:
(1) consider distinct / eliminate any duplicate ADASNO row (whichever is insignificant as long as ADASNO has no duplicates) (2) and ONLY then creates a fourth column showing the total count for duplicate ORDERNO records that exist (Not in the table overall but within the new subset that has eliminated duplicate ADASNO records).
The target database is DB2. I currently don't know what version but will seek to ascertain this although I am assuming not a recent version.
My goal is a query that produces the following:
ADSTAT ADASNO ORDERNO ORDERNOTOTAL
40 ASN123 40303020 1
30 ASN124 40303021 2
30 ASN125 40303021 2
The solution needs to avoid use of the PARTITION keyword as this version of DB2 doesn't accept it.
I am still trying to establish the version of DB2 database, suffice to say it is not that recent.