azure-cosmos-db-emulator-docker icon indicating copy to clipboard operation
azure-cosmos-db-emulator-docker copied to clipboard

ORDER BY with a function (and GROUP BY too)

Open lionelc opened this issue 2 weeks ago • 0 comments

When using ORDER-BY with a function:

SELECT p.name FROM products p ORDER BY LENGTH(p.name) DESC

The query would fail, and there's the same issue with GROUP-BY.

Luckily, for ORDER-BY, there's a quick workaround:

SELECT p.name, LENGTH(p.name) AS p.namelen FROM products p ORDER BY p.namelen DESC

This is a known issue from our query backend and we already let that team know. If you find more tricks on its workaround, feel free to comment below.

lionelc avatar Nov 19 '25 23:11 lionelc