How to limit count of duplicate rows in oracle?

Member

by dedrick , in category: MySQL , 22 days ago

How to limit count of duplicate rows in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , 22 days ago

@dedrick 

To limit the count of duplicate rows in Oracle, you can use the following query:

1
2
3
4
5
6
7
SELECT *
FROM (
    SELECT column1, column2, COUNT(*)
    FROM your_table
    GROUP BY column1, column2
    HAVING COUNT(*) < 2
) t;


In this query, replace your_table with the name of your table and column1, column2 with the columns that you want to check for duplicates. The HAVING COUNT(*) < 2 condition will limit the output to only show rows that have less than 2 occurrences, thus removing any duplicates.