Thursday, April 5, 2012

SQL to find items that have more than one row

Query examples to find items that have more than one row in a table: SELECT department, COUNT(*) as "Number of employees" FROM employees WHERE salary > 25000 GROUP BY department HAVING COUNT(*) > 10; SELECT key FROM table group by key having COUNT(*) > 1