Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
0 votes
0 answers
91 views

Return multiple columns with aggregate functions [duplicate]

I am trying to figure out how to return multiple columns that correspond with the desired aggregate functions, max of a sum, in SQL. Based on data from CDC's Serotypes of concern: Illnesses and ...
2 votes
2 answers
98 views

postgres jsonb array aggregate functions

I have a table with data on user applications. It contains several fields: employee_id text, date date, app_info jsonb. +-------------+------------+------------+ | employee_id | date | app_info ...
-1 votes
2 answers
190 views

Calculate SUM over a primary key and between dates

My query: SELECT c.CustID, o.OrderID, SUM(ol.Qty * ol.Price) AS SUMOrder, AVG(SUM(ol.Qty * ol.Price)) OVER (PARTITION BY c.CustID) AS AVGAllOrders, COUNT(*) AS Countorders, SUM(...
1 vote
0 answers
109 views

A User Defined Aggregated Function fails to shape a Map<K, C> field, where C is an object coming from many rows

Edit: Progressing into this problem analysis, the management of the dataset nested values with tools that Spark offers since 3.1.x seems required. → It's my manner of filling nested objects hold by ...
4 votes
5 answers
184 views

Query to find the product name which has a continuous increase in sales every year

Product table with columns - PRODUCT_ID PRODUCT_NAME PRODUCT_ID PRODUCT_NAME 100 NOKIA 200 IPHONE 300 SAMSUNG 400 OPPO Sales table with columns - SALE_ID PRODUCT_ID YEAR QUANTITY Price SALE_ID ...
1 vote
1 answer
44 views

How to write a query with aggregates of json_array_elements in jOOQ

I have this query: SELECT organisation_id, count((j->>'invoiceId')) AS count, sum((j->>'advanceAmount')::numeric(20,4)) AS sum FROM runs LEFT JOIN jsonb_array_elements(...
0 votes
0 answers
84 views

PySpark with aggregations failing

I have a 106M dataframe with nested columns, that is, I have a few columns where the values are {[1,2,3,4,5], <timestamp>, 1, 2 ,3}. I'm trying to add a few more columns using when, then do an ...
1 vote
1 answer
120 views

Extended condition of aggregating functions SQL

I need group speed by ram and return MAX(speed), where at least one NULL in speed values will return NULL. ram speed 128 600 128 600 128 750 128 750 128 800 128 900 32 400 32 NULL 32 500 64 450 64 500 ...
0 votes
2 answers
60 views

SQL row-wise comparison within group

I am trying to compute the number of events that take place within 30 minutes of one another (variable n_within_30) on the same date and in the same location. I have tried to partition and group by ...
0 votes
1 answer
76 views

BigQuery aggregations on different level by grouping sets

I need to create an aggregation for each housing type (column type) for each destination. There is a hierarchy (product->sub_product) and (category->sub_category) and also product can have ...
0 votes
0 answers
50 views

How to get count of unique users [duplicate]

Have the following tables: Projects: id name 1 Project 1 2 Project 2 3 Project 3 Assignments: id project_id user_id 1 1 1 2 1 3 3 1 2 4 2 1 5 3 1 6 3 2 Users: id name 1 User 1 2 User 2 3 User 3 I'm ...
0 votes
0 answers
16 views

Finding the minimum date from a set of dates [duplicate]

I'm having an issue with my assignment where it's giving me more than one "minimum" date. The problem is to create a table variable that shows the earliest invoice sent by each vendor, ...
-1 votes
2 answers
137 views

How to sum up numbers in JSONB key-values in PostgreSQL (CockroachDB)?

I have a table with rows with a JSONB in this form (YAML here for readability): { foo: 500, bar: 12 } { foo: 500, bar: 18, zoo: 5 } ... There can be arbitrary keys in the objects, but always ...
-1 votes
1 answer
98 views

How can I apply a filter to a window function in Snowflake?

Suppose I have a table like this TRANSACTION_DATE BOOKED_DATE AMOUNT 2024年02月10日 2024年02月09日 50 2024年02月10日 2024年02月10日 50 2024年02月10日 2024年02月11日 50 2024年02月11日 2024年02月10日 50 2024年02月11日 2024年02月11日 50 2024-...
0 votes
1 answer
74 views

Find by array of Ids not working with Mongoose aggregate method

I would like to use the aggregate in mongoose to get documents that match the ids in the array. The array contains mongoose object ids. It is returning an empty array. Here is my code: let ...

15 30 50 per page
1
2 3 4 5
...
395

AltStyle によって変換されたページ (->オリジナル) /