Page properties report macro and child page numbers
Asked by joshdanhall:

Is it possible to include the child page number in the Page Properties report, so that we can sort by that field?

pagenum.png  
[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=11321){#link_11930f3ca2b795}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59510/1/pagenum.png){#display_11930f3ca2b795_0}


Answers:
author: Davin Studer
body: If you had the [SQL for Confluence](https://marketplace.atlassian.com/plugins/org.swift.confluence.sql) and [Run Self-Service Reports for Confluence](https://marketplace.atlassian.com/plugins/org.swift.confluence.run) add-ons this is what I would suggest. Without those I'm not sure how you would do it outside of creating your own add-on to output the page's order in the tree. I was not able to find a way to do it with a user maco ... that doesn't mean it can't be done. If anyone with some velocity chops knows how to get the page order with velocity feel free to call me wrong. Anyway, I'll post this for anyone else who does happen to have those add-ons that might want to do this.

image2014-10-16 9:24:43.png

Here is the SQL so that it can be cut and paste. It is indeed all necessary. I know it looks like you should just be able to query and get the CHILD_POSITION where the CONTENTID = '$page_id' but that only works if the pages have been manually ordered. If they are in default (alphabetic) order then the CHILD_POSITION column is actually NULL. Hence, the need to create the temp table with the identity column to auto number the rows.

```
declare @tempTable table (	POSITION  int identity(0, 1),	CONTENTID numeric(19, 0))insert into @tempTable (CONTENTID)                select CONTENTIDfrom CONTENTwhere PARENTID in (	select PARENTID	from CONTENT	where CONTENTID = '$page_id')order by CHILD_POSITION, TITLEselect POSITION + 1from @tempTablewhere CONTENTID = '$page_id'
```

[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=6558){#link_11930f415224a7}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59516/1/image2014-10-16%209%3A20%3A19.png){#display_11930f415224a7_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=6559){#link_11930f415224a7_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59516/2/image2014-10-16%209%3A3%3A45.png){#display_11930f415224a7_2}  
[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=6560){#link_11930f415224a7_1}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59516/3/image2014-10-16%209%3A18%3A21.png){#display_11930f415224a7_4}  
[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=6561){#link_11930f415224a7_2}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59516/4/image2014-10-16%209%3A20%3A51.png){#display_11930f415224a7_6}  
[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=6562){#link_11930f415224a7_3}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59516/5/image2014-10-16%209%3A24%3A43.png){#display_11930f415224a7_8}  
[](https://community.atlassian.com/t5/Confluence-questions/Page-properties-report-macro-and-child-page-numbers/qaq-p/352221?attachment-id=6563){#link_11930f415224a7_4}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/59516/6/image2014-10-16%209%3A24%3A10.png){#display_11930f415224a7_10}


author: joshdanhall
body: Steven, updated with screen shot of requirement showing page# column. David, I don't have those plugins.


author: Davin Studer
body: Do you happen to have both the sql and run plugins? If so then I have a solution that I have tested.


author: Steven F Behnke
body: could you mock something up and attach it as an image to your Question? I can't visualize what you want...


author: joshdanhall
body: I have structured it so that the report page is the 'parent' and the pages with the Page Properties are 'children' of that page. So it would be nice if the page number (i.e. their relative order) could be included in the parent report.


author: Davin Studer
body: What do you mean by the child page number?