SELECT COUNT(*) FROM (
SELECT DISTINCT
p.value AS __color__,
t.id AS ticket, summary,
t.type AS type, priority, owner, resolution, t.time AS created,
t.changetime AS modified, description AS _description,
reporter AS _reporter
FROM ticket t
LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'
LEFT JOIN ticket_change tc ON tc.ticket = t.id AND tc.author = %s
AND tc.field = 'comment'
WHERE t.status == 'closed'
ORDER BY
t.changetime DESC,
CAST(p.value AS integer),
t.type,
t.time
) AS tab
Note:
See TracReports
for help on using and creating reports.