Category "aggregate-functions"

Trying to call function by using db.eval("functionName()") in mongoDB compass version 4.4 But getting error as TypeError: db.eval is not a function

db.system.js.insertOne({ _id: 'getMachinewiseLogDat', value: function () { return db.Smx_22235_ShiftOEEDaily.aggregate([ { $group: {

Troubleshooting Errors with Two SUMs

I have a table, it's going to be used for a supplier scorecard, with eleven different fields that can be assigned a value of 1-5. Null values are allowed. I

Nesting json_agg() inside json_agg()

I have these 2 tables tasks and subtasks with these columns: Tasks id name description Subtasks id name description task_id I'm trying to do a query that would

Is there another way to write SUM(IIF([CONDITION], 1, 0))?

What SUM(IIF([CONDITION], 1, 0)) does is very simple. So simple, that what I really just want to write is COUNT([CONDITION]) (but that's invalid). Is there a sh

expression not in aggregate or GROUP BY columns

I have a table that contains the following columns: ProductID, ProductName, Price, CategoryID. The goal is to print all the details (ProductID, ProductName, Pri

PostgreSQL left join query object array aggregate

I have 2 tables: table "person" with columns: person_id, person_name table "pet" with columns: pet_id, owner_id, pet_name person data: 1, 'John' 2, 'Jill' 3,

How to get definition/source code of an aggregate in PostgreSQL?

I found this related answer useful: Export "Create Aggregate" functions from PostgreSQL But how do I get the CREATE AGGREGATE statement without a GUI client (

How to group multiple columns into a single array or similar?

I would like my query to return a result structured like this, where tags is an array of arrays or similar: id | name | tags 1 a [[1, "name1", "color1"

ARRAY_AGG() grouped by another column's values

Here's my table like below p_no type name value ------------------------ 1 A Tomy 1 1 A Nick 2 1 B Tomy 3 1 B Nick 4 1

GROUP BY + CASE statement

I have a working query that is grouping data by hardware model and a result, but the problem is there are many "results". I have tried to reduce that down to "

DISTINCT result of ARRAY_CONCAT_AGG in BigQuery

I need to compute distinct set of items from the aggregated arrays. I cannot use the array_concat as suggested in similar threads, as I don't know how many arra

How to order results of a query by the results of an aggregate function in ComosDb?

I use Cosmos Db and I need results to be sorted by the results of a COUNT. Instead of sorting the results each time myself (or create a service for it), I pre