jai prakash
jai prakash

Reputation: 21

Check for duplicate record in postgresql

I have one table in postgresql and my table contain one column of timestamp without timezone

i want to write one query which will check if same date inserted multiple times or not if same date present more than once query should return that date

like 12 Sep 2011,12 Sep 2011,12 Sep 2011,10 Sep 2011,

Here 12 Sep 2011 date is present more than once how to write query for that

Upvotes: 2

Views: 8182

Answers (2)

Marco Mariani
Marco Mariani

Reputation: 13766

If you have timestamps, you should drop the 'time' part:

SELECT time_column::DATE FROM my_table GROUP BY time_column::DATE HAVING COUNT(*) > 1

Upvotes: 1

reader_1000
reader_1000

Reputation: 2501

SELECT my_date FROM my_table GROUP BY my_date HAVING COUNT(my_date) > 1

Upvotes: 9

Related Questions