It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

SQL - Get all labels in per Space - Excluding Personal Spaces.

Currently I have this SQL which returns all spaces, their labels and how many times that label is used. This is great other than the fact that it also returns personal spaces. How can I tweak this SQL to filter out personal and only return global spaces?

 

select
spacename as "Space"
, name as "Label"
, count(name) as Count
from CONTENT_LABEL
left join LABEL
on CONTENT_LABEL.labelid = LABEL.labelid
left join CONTENT

1 answer

1 accepted

0 votes
Answer accepted
Dominic Lagger Community Leader Feb 20, 2020

Hi @Michael Schultz 

I think, this is what you need:

select c.spaceid, s.spacename, l.name, count(l.name) as Count from content_label cl
join CONTENT c on c.contentid = cl.contentid
join label l on l.labelid = cl.labelid
join spaces s on s.spaceid = c.spaceid
where c.CONTENT_STATUS != 'deleted' and c.contenttype != 'SPACEDESCRIPTION' and s.spacetype != 'personal'
group by c.spaceid, s.spacename, l.name
order by count desc

 Regards, Dominic

This works create! Thank you @Dominic Lagger 

Do you know where I can find a database map or sorts for Confluence? Wondering what reference you use when creating SQL like this.

Dominic Lagger Community Leader Feb 24, 2020

Hi,

My reference is the database itself :) I also didn't find some schema or documentation.  

I once went through all tables and analyzed their contents :)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

2,116 views 4 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you