Skip to content

Instantly share code, notes, and snippets.

@nprussell
Created June 15, 2016 10:22
Show Gist options
  • Save nprussell/56ccb44e7a2a593f609b36b265fc05e5 to your computer and use it in GitHub Desktop.
Save nprussell/56ccb44e7a2a593f609b36b265fc05e5 to your computer and use it in GitHub Desktop.
SELECT users.display_name, serialNumbers.location, COUNT(serialNumbers.Location) AS cnt
FROM tracking
INNER JOIN users ON tracking.user=users.id
LEFT JOIN serialNumbers ON serialNumbers.serial=tracking.computerSerial
GROUP BY serialNumbers.location
HAVING ( cnt > 0 )
ORDER BY cnt DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment