How to limit count of duplicate rows in oracle?

Member

by dedrick , in category: MySQL , 6 months ago

How to limit count of duplicate rows in oracle?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , 6 months 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.

Related Threads:

How to multiply rows in oracle query by count column?
How to group time column into 5 second intervals and count rows using presto?
How to remove duplicate rows in laravel?
How do you delete duplicate rows in mysql without an id column?
How to check duplicate rows in a csv file using php?
How to limit count(*) for sparql?