When requesting stories in a project and ordering them by rank e.g.
project = PROJ AND status not in (Closed, Done) order by RANK
I do get the right order for stories in the backlog. However if a sprint is active or has been prepared and contains a story with a low ranking value it will still be up top in the backlog view (showing up in the sprint) while it would be listed at the end by the above JQL.
Including the sprint in the query as so does also only help partially:
project = PROJ AND status not in (Closed, Done) order by Sprint, RANK
Problem with this is if a story has been in sprints before (so e.g. it has been part of a sprint two sprints ago but has been taken out again) it would be sorted to the very top even if it is in the backlog.
How can I write a query that will give me the same exact order that I see from top to bottom in my Scrum Backlog view.