0

Goal is to create a top ten list of returning clients. I have a "projects" table that also has a Client_ID for each project.

What I need is for the SQL query to return the top ten results for the Client_ID's that appear the most in the projects table.

I've tried this:

select COUNT(DISTINCT Client_ID) AS 'Top Clients' FROM projects;

But truthfully I am just not sure how I can do this.

thanks for any help!

mitch
  • 155
  • 5
  • 13

1 Answers1

0

Using this question MySQL: Count occurrences of distinct values

SELECT Client_ID, COUNT(*) as TopClient FROM projects GROUP BY Client_ID ORDER BY TopClient DESC LIMIT 10;

Does this do the trick?

Community
  • 1
  • 1
rock-ass
  • 475
  • 5
  • 16