Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,238
Community Members
 
Community Events
184
Community Groups

How to query Jira in MSSQL to get Issues that don't have a specific component or have no components?

Edited

I am trying to get all the open issues in a project that don't have a specific component attached to it. However when I do this, it does not pull back any issues that have no components at all. Therefore, an issue must have at least one component in order to come back in the results. How can I make it so that this is not a requirement?

What I am doing currently is gathering a distinct list of all the open issues and then selecting the issues from that list that do not have the component "Printed". However like I said, this does not incorporate issues with no components at all.

This is in Microsoft SQL to be clear.

Thanks

3 answers

Hi @Joe ,

What I have done was to create a distinct list of all projects with the issue numbers:

Select 

concat(concat(p.pkey,'-'),i.issuenum) as Issue_key, i.*

From jiraissue as i

inner join projects as p

on i.project = p.id

 

Once you have that - then use it as you main table and left join your component code output to it.

It will return NULL when there is no component for that issue specifically.

 

Hope it helps

0 votes
Dan Breyen
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.
Mar 24, 2023

I apologize, I don't have a database where I have SQL access to fully test, but wouldn't your query be something like ((component <> 'PRINTED') or (component is NULL))

depending on how the db treats 'no component' it could be an Empty string instead, so you would use (component = "") instead.

Hope that helps.

Thanks. The problem is that SQL with Jira reads each component on an issue as a separate row. So if a Jira issue has no components, it does not appear in the results

0 votes
Marco Brundel
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.
Mar 24, 2023

Hi @Joe ,

When you use JQL you can try this:

component != Printed OR component IS EMPTY

Regards, Marco 

Hi. This is in Microsoft SQL unfortunately, not JQL. I have updated the post. Thanks

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 24, 2023

I recommend that you stop using SQL to do this sort of reporting.

SQL can't report on what is not there, which is what you have here.  The Jira database really isn't designed for reporting and SQL is the worst possible way to read it.

As @Marco Brundel points out, JQL can answer the question, and it is a lot easier to use than SQL

Like Marco Brundel likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events