my $duplicates= $dbh->selectall_arrayref("SELECT ID, Tag1, Tag2, COUNT(*) c FROM table GROUP BY Tag1, Tag2 HAVING c > 1");