none
Azure cosmos db alias column order by RRS feed

  • Question

  • I have written a select query in cosmos db which works fine. But in that query when i try to add order by column on a alias column it does not work. Here distance is an alias column What is the correct way to do it ?

    SELECT c.id,c.type,c.name,c.latitude,c.longitude,c.location,

    ST_Distance(c.location, { 'type': 'Point', 'coordinates':[-112.215641, 33.181647]}) as distance

    FROM c WHERE ST_Distance(c.location, { 'type': 'Point', 'coordinates':[-112.215641, 33.181647]}) < 321868.8

    ORDER BY c.distance ASC

    Wednesday, August 21, 2019 6:39 PM

Answers

  • Hi Nitin

    Currently the "Ordering results by the ST_DISTANCE spatial function is currently not supported" in Cosmos DB. There is already a topic for the same in User Voice .

    The Cosmos Team has already planned it for implementation but there is no time line associated with the same. You can also vote for the feature.

    This is not much but hope it helps you to plan.

    Thanks
    Navtej S

    Thursday, August 22, 2019 9:02 PM
    Moderator

All replies

  • Hi Nitin,

    What error you are getting?


    Cheers,

    Thursday, August 22, 2019 3:53 AM
  • Hi Amit,

    I get the count as 0. The moment i apply order by clause

    Thursday, August 22, 2019 11:58 AM
  • Hi Nitin

    Currently the "Ordering results by the ST_DISTANCE spatial function is currently not supported" in Cosmos DB. There is already a topic for the same in User Voice .

    The Cosmos Team has already planned it for implementation but there is no time line associated with the same. You can also vote for the feature.

    This is not much but hope it helps you to plan.

    Thanks
    Navtej S

    Thursday, August 22, 2019 9:02 PM
    Moderator