Skip to content

Instantly share code, notes, and snippets.

@exhuma
Created June 27, 2013 12:02
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 exhuma/5875917 to your computer and use it in GitHub Desktop.
Save exhuma/5875917 to your computer and use it in GitHub Desktop.
Redmine query aimed at the "my page" route.
-- The following query conbines the task due-date with the priority and sorts with the combined value.
SELECT id, project_id, subject, due_date, status_id,priority_id,author_id, priority_id * EXTRACT(EPOCH FROM AGE(due_date))
FROM issues
WHERE assigned_to_id=3 OR
author_id=3 AND
status_id IN (SELECT id FROM issue_statuses WHERE NOT is_closed)
ORDER BY (priority_id * EXTRACT(EPOCH FROM AGE(due_date))) DESC NULLS LAST,
priority_id DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment