I need to query my database to show the records inside my table where lastname occurs more than three times. Example: in my Students Table, there are 3 people with Lastname
For postgresql:
SELECT * AS rec FROM ( SELECT lastname, COUNT(*) AS counter FROM students GROUP BY lastname) AS tbl WHERE counter > 1;