nosql-aggregation

How do I enforce ordering (ORDER BY) in a custom Presto Aggregation Function

筅森魡賤 提交于 2021-01-28 01:45:34
问题 I am writing a custom Presto Aggregation Function that produces the correct result if (and only if) the values are ordered in ascending order by the value that I am aggregating on. i.e. The following will work: SELECT key, MY_AGG_FUNC(value ORDER BY value ASC) FROM my_table GROUP BY key The following will yield an incorrect result: SELECT key, MY_AGG_FUNC(value) FROM my_table GROUP BY key When developing the MY_AGG_FUNC , is there a way to enforce ORDER BY value ASC internally without relying

How can I sum total of cancellation per month grouped by years in MongoDB?

你离开我真会死。 提交于 2020-03-25 17:57:52
问题 I am optimizing an end-point for my API, and I would like to get the total of cancellations of Service A, B and others from Jan to Dec grouped by year. This is the output that I would love to get from my end-point: [ { "_id:"{ "name": "Product A" }, "2017": { "January": 2500, "February": 3000, "March": 1500, "April": 4500, "May": 3250, "June": 9080, "July": 1120, "August": 890, "September": 5789, "Octuber": 7899, "November": 3459, "Decemeber": 2300 }, { "_id": { "name": "Product B", }, "2018"

How can I sum total of cancellation per month grouped by years in MongoDB?

喜欢而已 提交于 2020-03-25 17:57:27
问题 I am optimizing an end-point for my API, and I would like to get the total of cancellations of Service A, B and others from Jan to Dec grouped by year. This is the output that I would love to get from my end-point: [ { "_id:"{ "name": "Product A" }, "2017": { "January": 2500, "February": 3000, "March": 1500, "April": 4500, "May": 3250, "June": 9080, "July": 1120, "August": 890, "September": 5789, "Octuber": 7899, "November": 3459, "Decemeber": 2300 }, { "_id": { "name": "Product B", }, "2018"

Firebase mimicing WHERE IN

六月ゝ 毕业季﹏ 提交于 2020-01-07 08:01:49
问题 Given the date model provided below, after a user logs in and retrieves their data, they can also get a list of their friends. However, in order to now attain details of those two friends by ids fdb17f3a-7b7d-4aa5-9a0b-b9fb33c349de and a96da7b1-7c4e-44bc-b82e-fc75bed52bcd , at present, the most efficiently operation appears to simply be to loop through the urls, in such a way as: for singleFriendID in allFriendIds firebase.com/[my_db_name]/users/{singleFriendID} end but even that has its

Firebase mimicing WHERE IN

橙三吉。 提交于 2020-01-07 08:01:02
问题 Given the date model provided below, after a user logs in and retrieves their data, they can also get a list of their friends. However, in order to now attain details of those two friends by ids fdb17f3a-7b7d-4aa5-9a0b-b9fb33c349de and a96da7b1-7c4e-44bc-b82e-fc75bed52bcd , at present, the most efficiently operation appears to simply be to loop through the urls, in such a way as: for singleFriendID in allFriendIds firebase.com/[my_db_name]/users/{singleFriendID} end but even that has its

MAX(), DISTINCT and group by in Cassandra

拜拜、爱过 提交于 2019-12-17 07:31:38
问题 I am trying to remodel a SQL database Cassandra such that, I can find the Cassandra equivalent for the SQL queries. I use CQL 3 and Cassandra v1.2. I modeled the db design in cassandra so that it supports the order by clauses and denormalized tables to support the join operation. However I am at sea when it comes to DISTINCT, SUM() and GROUPBY equvalents SELECT a1,MAX(b1) FROM demo1 group by a1. SELECT DISTINCT (a2) FROM demo2 where b2='sea' SELECT sum(a3), sum(b3) from demo3 where c3='water'

How to use $update/ $set operator in aggregation pipeline mongodb?

狂风中的少年 提交于 2019-12-13 04:16:00
问题 I am trying to update a field called name in my coll1 collection based on certain criteria. I first created a create an aggregation pipeline that filters out documents based on my criteria. var local_filter = { "$or" :[ {'fullText': {'$eq': "404 Error"}}, {'fullText': {'$eq': "Unknown Error"}}, {'fullText': {'$eq': "503 Error"}}, {'fullText': {'$eq': "400 Error"}}, {'fullText': {'$eq': "500 Error"}}, {'fullText': {'$eq': "Read timed out"}}, {'fullText': {'$eq': "410 Error"}}, {'fullText': {'