Questions tagged [aggregate]

Aggregate is the term used to describe the act of condensing grouped data, a technique heavily employed in the field of Statistics.

Utilizing JSON object nesting to organize the results of PostgreSQL relational queries

There are three tables in my database: "parent", "children", and "grandchildren". These tables have many-to-many relationships. In addition to the main tables, there are also two relational tables. I want to create a query that will return all parent elem ...

Using $regex in mongodb's pipeline operations allows for advanced string

I need to be able to use $regex in order to search for any words that contain a specific keyword provided by the user, but I'm experiencing issues. Here's what I have so far: aggregatePipeline.push({ $match: { name: { $reg ...

Is there a recursive method to verify the folder name for each aggregate?

Consider the scenario with these sample documents: (parent_id: null denotes items located at root directory) {"_id":"a", "name":"Pictures", "parent_id": null, "type": "folder"} {"_ ...

Generate summary columns using a provided list of headers

In my dataset, there is survey data along with columns containing demographic information such as age and department, as well as ratings. I want to enhance the dataset by adding new columns based on calculations from the existing rating columns. The goal ...

The Aggregation Projection Query encountered an error due to an unrecognized expression

Error in $project :: caused by :: Unrecognized expression '$$varientPricePoint.ppId' { "pricepoint": { "$filter": { "input": "$OriginalPricePoints", "as": "varien ...

Find the difference between array_A and the documents in array_B using MongoDB's $match operator, and return the result as Array_C

I need to create an array_C that includes only the elements from array_A that are not present in array_B. My approach involves using $match in aggregate to specify array_B. For instance: array_A = [1, 2, 3] array_B = [2, 4, 6, 8, 10] array_C = [1, 3] I a ...

Calculate the sum of each column in a pandas dataframe using user-defined functions in Python

Showing my dataset: df = [{'id': 1, 'name': 'bob', 'apple': 45, 'grape': 10, 'rate':0}, {'id': 1, 'name': 'bob', 'apple': 45, 'grape': 20, ...

I'm having trouble getting the aggregation of a child collection to work properly in MongoDB when attempting to apply the $count

Could someone help me troubleshoot my aggregate query? I'm trying to sum the count values for each beacon, but it keeps returning 0. Please let me know if you spot any mistakes in the query. Sample Data [ { ...

Generating a fresh variable through aggregation in Python 2

I have collected data on births that is structured like so: Date Country Sex 1.1.20 USA M 1.1.20 USA M 1.1.20 Italy F 1.1.20 England M 2.1.20 Italy F 2.1.20 Italy M 3.1.20 USA F 3.1.20 USA F My goal is to transfor ...

What is the process for combining two values from a JSON-array in a specific sequence?

Currently, I am utilizing PostgreSQL 9.5 and have a table containing JSON arrays with JSON objects structured like so: [] [{animal:cat}, {plant:sunflower}, {car:mercedes}] [{animal:dog}] [{animal:dog}, {car:audi}] [] The goal is to present a table that m ...