Skip to content

Instantly share code, notes, and snippets.

@bgK

bgK/14.sql Secret

Created November 7, 2019 19:28
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 bgK/d27d5efef8651abc2bcf01a0b1ece5c6 to your computer and use it in GitHub Desktop.
Save bgK/d27d5efef8651abc2bcf01a0b1ece5c6 to your computer and use it in GitHub Desktop.
SELECT *
FROM
(SELECT pr.value AS __color__,
t.id,
t.summary,
COALESCE(
(SELECT tch.author
FROM ticket_change tch
WHERE tch.ticket = t.id
AND tch.field = 'comment'
ORDER BY tch.time DESC
LIMIT 1), '(none)') "Last Comment By",
t.status,
t.type,
t.priority,
t.component,
t.time created,
t.reporter reporter,
t.changetime modified,
tc.value game
FROM ticket t
LEFT OUTER JOIN ticket_custom tc ON tc.ticket = t.id
AND tc.name = 'game'
LEFT OUTER JOIN enum pr ON pr.type = 'priority'
AND pr.name = t.priority
WHERE t.status != 'closed' ) AS sub
WHERE ("Last Comment By" = '(none)'
AND reporter <> '%s')
OR ("Last Comment By" <> '(none)'
AND "Last Comment By" <> '%s')
ORDER BY modified DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment