In the following query, we list all lastname held by 2 or more employees.

SELECT lastname, COUNT(*) c FROM employees GROUP BY lastname HAVING c > 1;

If you want a value to be unique, you should add a unique constraint to the column. However, you would from time to time have to deal with a badly designed database. In such cases, this query will come in handy.

By master