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
From Oracle (but works in most SQL DBs):
SELECT LASTNAME, COUNT(*) FROM STUDENTS GROUP BY LASTNAME HAVING COUNT(*) >= 3
P.S. it's faster one, because you have no Select withing Select methods here