Question : SQL to count distinct if a value appears more than 5 times

Hi Experts,
I am looking for the SQL Query to Count Distict values in a field where the vaule appears more than 5 times. Therefore a field that contains Harry (ten times), Paul (4 times) and John (6 times) would return a value of "2"
Anyone knwo how? I am using count distinct, but I want to ignore any values that occur less than 5 times.
Kind regards,
Kevin

Answer : SQL to count distinct if a value appears more than 5 times

hi kevinsmith121,

Try this

SELECT COUNT(*)
FROM
  (SELECT fieldname
   FROM tablename
   GROUP BY fieldname
   HAVING COUNT(*)>5
  ) T
Random Solutions  
 
programming4us programming4us