Skip to content

Instantly share code, notes, and snippets.

@julestruong
Created May 24, 2019 16:19
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 julestruong/cb698c8da018b635d9d67cdcea8aa9e8 to your computer and use it in GitHub Desktop.
Save julestruong/cb698c8da018b635d9d67cdcea8aa9e8 to your computer and use it in GitHub Desktop.
offers moderated more than once
SELECT
COUNT(count) nb_remoderation,
month
FROM
(
SELECT count(1) count,
DATE_FORMAT(logged_at, '%Y-%m') month
FROM office_offer oo
INNER JOIN office_offer_log log ON log.object_id = oo.id
WHERE JSON_CONTAINS(log.data, '"moderation"', '$.state')
GROUP BY DATE_FORMAT(logged_at, '%Y-%m'), oo.id
HAVING Count(1) > 1
) sub
-- WHERE sub.month ="2018-01"
GROUP BY month;
SELECT
COUNT(count) nb_remoderation,
month
FROM
(
SELECT count(1) count,
DATE_FORMAT(logged_at, '%Y-%m') month
FROM room_offer ro
INNER JOIN office_offer_log log ON log.object_id = ro.id
WHERE JSON_CONTAINS(log.data, '"moderation"', '$.state')
GROUP BY DATE_FORMAT(logged_at, '%Y-%m'), ro.id
HAVING Count(1) > 1
) sub
-- WHERE sub.month ="2018-01"
GROUP BY month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment