SQL2: order node by path
Hi,
I am working on a structure like this:
/content
/myapp
/archive
/2014
/08
page
page
page
/07
page
page
/2013
/10
page
page
page
/09
page
page
Let's suppose you want to query the crx in order to retrieve these pages. A possible way to achieve this is the following:
select * from [cq:Page] as pageItem where isdescendantnode(pageItem, [/content/myapp/archive])
Everything works fine, but nodes are retrieved in an order that doesn't make much sense to me. I would like them to be ordered by path: in this particular case, this would mean having them ordered by date. I know a similar result could be achieved by setting a property on each node and use it to handle the ordering, but:
- there could be a huge amount of already existing nodes with no date-related property whatsoever
- such information would be redundant, given the structure highlighted above
Unfortunately, creation date and last modified date cannot be used: I may create today a page that was meant to be created back in 2010.
Does anyone know how to do it?
Thanks!