Skip to content

Instantly share code, notes, and snippets.

@hshoff
Created February 25, 2013 18:51
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 hshoff/5032222 to your computer and use it in GitHub Desktop.
Save hshoff/5032222 to your computer and use it in GitHub Desktop.
SELECT u.country, COUNT(distinct user_id), COUNT(distinct hosting_id), COUNT(*)
FROM users u
JOIN hostings h ON (u.id = h.user_id)
JOIN reservations r ON (u.id = r.host_id)
WHERE h.has_availability = '1' AND r.status = '1' AND r.created_at >= '2011-01-01'
GROUP BY u.country;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment