Skip to content

Instantly share code, notes, and snippets.

@Fuzzwah
Created August 16, 2019 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuzzwah/fb6ec5eef1cabb6e5f62628edd30e980 to your computer and use it in GitHub Desktop.
Save Fuzzwah/fb6ec5eef1cabb6e5f62628edd30e980 to your computer and use it in GitHub Desktop.
SELECT  
  DISTINCT event_result.club,  
  driver_counts.driver_count  
FROM event_result   
JOIN (  
  SELECT distinct_drivers.club,   
  COUNT(1) AS driver_count  
  FROM (  
    SELECT DISTINCT custid, club  
    FROM event_result  
  ) AS distinct_drivers  
  GROUP BY distinct_drivers.club  
) AS driver_counts   
ON driver_counts.club = event_result.club  
ORDER BY driver_counts.driver_count DESC  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment