SQL templates/Generic SQL

Find duplicate values in a column

Surface values that appear more than once — duplicate emails, SKUs, order references.

Generic SQL · PostgreSQL
SELECT email,
       COUNT(*) AS occurrences
FROM customers
GROUP BY email
HAVING COUNT(*) > 1
ORDER BY occurrences DESC;

How it works

Groups by the column and keeps only the groups with more than one row, so you can spot and clean up duplicates. Replace `customers` and `email` with your table and column.

Run this on your own database

BeQuery mirrors your Generic SQL MySQL database to an isolated PostgreSQL copy, so you can run queries like this one without ever touching production.

Start free No credit card

More Generic SQL queries