Skip to content

Instantly share code, notes, and snippets.

@reneeb
Created December 21, 2017 20:29
Show Gist options
  • Save reneeb/dab6e555b0bcd3c0385460673194950c to your computer and use it in GitHub Desktop.
Save reneeb/dab6e555b0bcd3c0385460673194950c to your computer and use it in GitHub Desktop.
SELECT count( a.ticket_id ), t.name
FROM article a
INNER JOIN article_type t
ON a.article_type_id = t.id
INNER JOIN article_sender_type st
ON a.article_sender_type_id = st.id
WHERE a.id = (
SELECT MIN(id)
FROM article a2
WHERE a2.ticket_id = a.ticket_id
)
AND a.create_time BETWEEN '2017-12-21 15:00:00' AND '2017-12-21 21:00:00'
GROUP BY a.article_type_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment