How to group by and order by in cosmos db?

陌路散爱 提交于 2020-01-25 07:23:08

问题


As this doc said, "You currently cannot use GROUP BY with an ORDER BY clause but this is planned". But we do need to group by one field and order by another field. Is there a way to do it?


回答1:


According to my research, i'm afraid that there is no such direct official way to use GROUP BY with ORDER BY since the statement you mentioned in your question:

The GROUP BY clause must be after the SELECT, FROM, and WHERE clause and before the OFFSET LIMIT clause. You currently cannot use GROUP BY with an ORDER BY clause but this is planned.

You could submit your feedback to push the progress of this feature.

If your need is urgent,i would suggest you :

  • a:sort the date after group by.Such as ARRAY.SORT() method in .net code.
  • b:Or you could group by the data with this package(which is built on Stored Procedure in cosmos db) after order by.


来源:https://stackoverflow.com/questions/59185057/how-to-group-by-and-order-by-in-cosmos-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!