You are asking about and aggregate query:

Code:
SELECT patient, COUNT(*)
  FROM appointment
 GROUP BY patient
ORDER BY 1;