Skip to content

Instantly share code, notes, and snippets.

@zdepablo
Last active August 29, 2015 14:13
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 zdepablo/3587a6755b080b85136c to your computer and use it in GitHub Desktop.
Save zdepablo/3587a6755b080b85136c to your computer and use it in GitHub Desktop.
textalytics-queries per use
#Number of active users per service - with a cutoff
SELECT `service`, COUNT(*) num_users
FROM
(
SELECT `service`, `hash_key`, COUNT(*) num_requests
FROM `log`
WHERE `date_operation` > '2014-12-01'
GROUP BY `service`, `hash_key`
ORDER BY num_requests DESC
) active
WHERE num_requests > 100
GROUP BY service
ORDER BY num_users DESC
#active users per service - with a cutoff
SELECT email, log.`service`, log.`hash_key`, COUNT(*) num_requests
FROM log JOIN license
ON (log.service, log.hash_key) = (license.service, license.hash_key)
WHERE `date_operation` > '2014-12-01'
GROUP BY log.`service`, log.`hash_key`
HAVING num_requests > 100000
ORDER BY num_requests DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment