I am trying to capture several nodes of the same type from different areas in jcr and sort them by date.
SELECT * FROM [social:asiResource]
WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND
[isFeatured_b] = true AND
NOT CONTAINS([cq:tags],'administrative:blacklist') AND
(ISDESCENDANTNODE([/path/to/content]) OR
ISDESCENDANTNODE([/path/to/content]))
ORDER BY [cq:lastModified] DESC
This will return me the correct set of results, but not in the correct order. In fact, the change DESC
to ASC
not change the results.
My solution at the moment is to execute several queries and do a join that allows it to ORDER BY
function as it should.
SELECT * FROM [social:asiResource]
WHERE [sling:resourceType] = 'social/qna/components/hbs/topic' AND
[isFeatured_b] = true AND
NOT CONTAINS([cq:tags],'administrative:blacklist') AND
ISDESCENDANTNODE([/path/to/content])
UNION
SELECT * FROM [social:asiResource] WHERE
[sling:resourceType] = 'social/qna/components/hbs/topic' AND
[isFeatured_b] = true AND
NOT CONTAINS([cq:tags],'administrative:blacklist') AND
ISDESCENDANTNODE([/path/to/content])
ORDER BY [cq:lastModified] DESC
Unfortunately, I have about 30 nodes that I am looking to make the last request unusable. Is there any way to use ORDER BY
without using UNION
?