This question is related to my previous question :
error of finding distinct cobinations of muiltiple columns in IBM netezza SQL table
Now, I need to find some partial duplicated rows in the table in SQL IBM netteza Aiginity workbench.
The table is like :
id1 id2 **id3 id4 id5 id6** id7 id8 id9
NY 63689 eiof 394 9761 9318 2846 2319 215
NY 63689 eiof 394 9761 9318 97614 648 645
CT 39631 pfef 92169 9418 9167 164 3494 34
CT 39631 pfef 92169 9418 9167 3649 7789 568
id3 id4 id5 id6 are duplicated for id1 = NY and id2 = 63689
id3 id4 id5 id6 are duplicated for id1 = CT and id2 = 39631
The result should be
id1 id2 value
NY 63689 2
CT 39631 2
UPDATE: I only need to count the partial duplicated for id3 id4 id5 id6 for each id1 and id2. I do not care the columns of id7, id8, id9.
I used the sql query:
SELECT id1, id2,
COUNT(*) AS value
FROM
(
SELECT
id1, id2, id3, id4, id5, id6
FROM
myTable
GROUP BY
id1, id2, id3, id4, id5, id6
)
AS uniques
GROUP BY
id1, id2
But, I got:
id1 id2 value
NY 63689 number of combinations of id7 id8 id9
CT 39631 number of combinations of id7 id8 id9
Any help would be appreciated.