Thursday, July 2, 2009

SQL: query occurrences of multiple fields in a table

SELECT id, name , email,
COUNT(id) AS NumOccurrences
FROM student_record
GROUP BY id, name, email
HAVING ( COUNT(id) > 1 );

- student_record is table name.
- id, name, email are column names.
- counting more than one occurrences for above column.