I have two tables, PATIENT and VISIT. One with PatientID as the primary key and one with VisitID as the primary key. I need to select the first name and last name of the patients that have visited the hospital more than twice.
I have tried DISTINCT, a nested where clause, INNER JOIN, etc.
SELECT FirstName
, LastName
, PatientID
, COUNT(*) AS total_visits
FROM VISIT
WHERE total_visits > 2;
It should just show the first and last name of the patients that have more than two occurrences in the VISIT table, but no matter how I rearrange the code it doesn't work.