作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 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/
我是一名优秀的程序员,十分优秀!