SQL2 Query | Community
Skip to main content
May 16, 2023
Solved

SQL2 Query

  • May 16, 2023
  • 2 replies
  • 746 views

Hello All,

 

I have a requirement to remove 'order by' on 'created date' and return the results as added in author dialog.

 

For Instance - Query is

 

SELECT p.* FROM [cq:PageContent] AS p WHERE ISDESCENDANTNODE(p, [/content/test/en]) AND p.[cq:template] = '/conf/test/settings/wcm/templates/test1' AND ( p.[jcr:path] in ('/content/test/en/second/jcr:content','/content/test/en/first/jcr:content') )

So, expectation is to get results in the same order (as added in query) -

 

- /content/test/en/second/jcr:content - /content/test/en/first/jcr:content

 

whereas, In actual, getting the results like this

 

- /content/test/en/first/jcr:content - /content/test/en/second/jcr:content

 

Any Suggestions ?

 

Thanks !!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ritesh_Mittal

Hi @srajput-woolies ,

 

It seems the natural ordering is being applied by default. Is it possible you can apply sorting based on some attribute you are going to fetch from theses nodes as per business requirement?

 

Another solution is to run the query on each node and then add the result.

 

Thanks,

Ritesh Mittal

2 replies

Ritesh_Mittal
Community Advisor and Adobe Champion
Ritesh_MittalCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
May 16, 2023

Hi @srajput-woolies ,

 

It seems the natural ordering is being applied by default. Is it possible you can apply sorting based on some attribute you are going to fetch from theses nodes as per business requirement?

 

Another solution is to run the query on each node and then add the result.

 

Thanks,

Ritesh Mittal

BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 16, 2023

What's the exact usecase? Maybe instead of using the JCR_SQL2, you can get the resource of that particular path, and then get childrens of that resource?