List of Projects, Project Categories, and Project Leads

Neha Pande December 19, 2017

I am working on a SQL query to extract the projects their leads and the project category. I was able to extract this with the below query

select pc.id,pc.cname, p.id, p.pname from nodeassociation na, projectcategory pc, project p
where na.sink_node_id=pc.id and
na.source_node_id=p.id and
na.sink_node_entity='ProjectCategory' and
na.association_type='ProjectCategory'
order by pc.cname;

OR

select p.id, p.pname, p.lead, na.sink_node_id, na.sink_node_entity, pc.cname from jiradb.jiraschema.project p
left outer join jiradb.jiraschema.nodeassociation na ON na.source_node_id=p.id
Inner join jiradb.jiraschema.projectcategory pc ON na.sink_node_id=pc.id
WHERE
na.sink_node_entity='ProjectCategory' and
na.association_type='ProjectCategory'

but there is a glitch in this. I have some projects which does not have any category my query doesn't extract those projects. I have looked into node association and there is no entry for that project for project category even with value null. It seems kind of not possible to me. If anyone is having a clue of how to do it. Please let me know.

1 answer

0 votes
Alexey Matveev
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.
December 19, 2017

Hello,

Use outer join the get the lines with null values. It would be something like this

select p.id, p.pname, p.lead, na.sink_node_id, na.sink_node_entity, pc.cname from jiradb.jiraschema.project p
left outer join jiradb.jiraschema.nodeassociation na ON na.source_node_id=p.id
left outer join jiradb.jiraschema.projectcategory pc ON na.sink_node_id=pc.id
WHERE
na.sink_node_entity='ProjectCategory' and
na.association_type='ProjectCategory'

Neha Pande December 20, 2017

Hey Alexey, 

Thank you for response. Even with above query I am getting the exact same result as I was getting with my query, It does not retrieve the project with no category.

Like Alexander likes this
Om Joshi July 20, 2022

this is nice but is there any option to achieve below type of list

Project Key

Project Description

Project Lead

Project Lead Email

Project Category

Project URL

Project Create Date

Project Name

Suggest an answer

Log in or Sign up to answer