Wrong sorting order of numerical strings

We would like to be able to filter/sort by appVersion which has the following format:


These are being sent as strings. The problem is that when I run this query I can see that New Relic doesn’t sort them as number but as strings instead which leads to wrong results.

The query used is:

SELECT count(*) FROM MobileSession FACET appVersion, numeric(appBuild) LIMIT 1000 WHERE osName = ‘iOS’ SINCE 1 week ago

The correct output should be this:

But if I sort by app version I get this instead:

Again if sorted by appBuild (which is also a string) I get wrong results:

I have also tried using the numeric(…) on the facet string properties but still got wrong results.

Hi @apinho1!

This is a commonly requested feature request as NRQL does not currently support ORDER BY. Per our documentation:

The facets are sorted in descending order by the first field you provide in the SELECT clause. If you are faceting on attributes with more than 1,000 unique values, Insights picks a subset of facet values and sorts them according to the query type.


1 Like