Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JQL - how to sort query results by whether a field is blank

Kyra Neal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 9, 2022

I'd like my query to put issues assigned to someone at the top, and order those by when they were updated. 

My current query is as follows: 

"Epic Link" in ([relevant epics]) ORDER BY assignee, updated DESC, summary ASC

This results in the query ordering by assignee ASC, which makes sense. Is there a way to put a binary variable in the sorting piece of the code?

I.e., is it possible to do something like: "ORDER BY [assignee <> blank], updated DESC, summary ASC"?  

Thanks in advance for the help.

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2022

Hi @Kyra Neal -- Welcome to the Atlassian Community!

JQL is not an SQL, and so does not have many features of an SQL...such as what you asked.

What you can do is sort by the assignee and the non-blank ones will go to the top:

project = yourProjectName AND "Epic Link" IN (your list of epics) ORDER BY assignee ASC, updated DESC, summary ASC

If you want to exclude the unassigned issues, try adding:

AND assignee IS NOT EMPTY

 

Kind regards,
Bill

0 votes
Adam Rypel _MoroSystems_
Community Champion
November 9, 2022

Hello @Kyra Neal ,

I am not sure if I understand - you say you want to put issues assigned to someone at the top, but the query "ORDER BY assignee, updated DESC, summary ASC" does exactly that - or not? Assignees are sorted alphabetically from the top and unassigned are on the bottom.

Or what you want to achieve is to leave out unassigned issues?

Suggest an answer

Log in or Sign up to answer