gpt4 book ai didi

Azure Cosmos 数据库别名列排序依据

转载 作者:行者123 更新时间:2023-12-05 02:59:46 25 4
gpt4 key购买 nike

我在 cosmos db 中编写了一个选择查询,效果很好。但在该查询中,当我尝试在别名列上按列添加顺序时,它不起作用。这里的距离是一个别名列,正确的方法是什么?

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

最佳答案

实际上,我们被告知只能根据文档的属性进行排序,而不能根据派生值进行排序。请看这个link .您的distance列是派生值,不能用于order by

“Unsupported ORDER BY clause. ORDER BY item expression could not be mapped to a document path”

我建议你自己对查询结果进行排序。例如,在.net代码中,你可以使用 Sort函数按列对结果进行排序。

关于Azure Cosmos 数据库别名列排序依据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57595811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com