Skip to Content
0
Former Member
Jul 22, 2016 at 07:36 PM

flexible search order by is not working as expected with order by DESC and ASC

791 Views

Sort order is not working as expected with order by DESC and ASC

Sample Query below: query one: SELECT {pk}, {totalprice}, {creationtime}, {code}, {status} FROM {Order} WHERE {versionID} IS NULL ORDER BY {totalprice} DESC

query two SELECT {pk}, {totalprice}, {creationtime}, {code}, {status} FROM {Order} WHERE {versionID} IS NULL ORDER BY {totalprice} ASC

All queries give inaccurate results because they are being ordered by {pk} and not {totalprice}

In order to get the queries to sort in the correct order I have to put the column in the order by column in the first position in the query. Example below:

SELECT {totalprice}, {pk}, {creationtime}, {code}, {status} FROM {Order} WHERE {versionID} IS NULL ORDER BY {totalprice} ASC

This is a problem because the out of box code is expecting {pk} to the be first column in the select statement. So the query above will throw exceptions.

Is anyone else having this issue? This happens in HAC and my code base