Skip to content

Instantly share code, notes, and snippets.

@andrewpurcell
Created April 5, 2012 05:58
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 andrewpurcell/2308335 to your computer and use it in GitHub Desktop.
Save andrewpurcell/2308335 to your computer and use it in GitHub Desktop.
select a winner for sentegy
SELECT * FROM
(
SELECT DISTINCT comfortfeedback.PersonID,
COUNT(comfortfeedback.PersonID) as c,
people.name,
people.email
FROM comfortfeedback, people
WHERE comfortfeedback.TimeStamp >= DATE('2012-3-26')
AND people.PersonID = comfortfeedback.PersonID GROUP BY PersonID
) as t1
WHERE c >= 4
ORDER BY rand()
LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment