title: how to get the max() value from a count() on sql?
body: <p>i have the following tables:
  VISITS: vid, pid, date
  PATIENT: pid, pname, age, gender . 
  what i want is to get the patient with more visits by using a count and a max function.
  i did the count with this query:</p>
  
  <p>select  Patient.pname, count (Visits.pid) as PatientsVisits
  from (
  Patient inner join Visits
  on Patient.pid = Visits.pid)
  group by Patient.pname</p>
  
  <p>So my output displays the patient's name and the number of visits each one has.</p>
  
  <p>So how can i get the max value ??
  ps: im using sql server</p>