membersound
membersound

Reputation: 86837

How to select all non-distinct rows from a DB?

This will give me all unique entries:

select distinct (origin, destination) from mytable

but how can I select all routes that are non-unique instead? So I get the rows that are dublicate regarding these 2 fields?

Upvotes: 2

Views: 142

Answers (1)

Saharsh Shah
Saharsh Shah

Reputation: 29051

Try this:

SELECT origin, destination 
FROM mytable
GROUP BY origin, destination
HAVING COUNT(*) > 1

Upvotes: 5

Related Questions