Skip to content

Instantly share code, notes, and snippets.

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/c98b8e4ac1705822739dabb8b7bd35db to your computer and use it in GitHub Desktop.
Save julestruong/c98b8e4ac1705822739dabb8b7bd35db to your computer and use it in GitHub Desktop.
offers nb moderation by month
SELECT
COUNT(count),
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 oo.id, month
) sub
GROUP BY month;
SELECT
COUNT(count),
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 ro.id, month
) sub
GROUP BY month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment