Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
82 views

I'm trying to calculate the percentage contribution of each firm to the total amount across all firms. Database: google-bigquery What I need (desired output): Sum usde_haircut_amt per firm Compute ...
sandesh kamera's user avatar
3 votes
3 answers
147 views

I have a SQL table in postgres 14 that looks something like this: f_key data1 data2 fit 1 {'a1', 'a2'} null 3 1 {'b1', 'b2'} {'b3'} 2 2 {'c1', 'c2'} null 3 Note that data1 and data2 are arrays. I need ...
fitek's user avatar
  • 303
2 votes
2 answers
140 views

As Postgresql documentation states in # 36.12.4. Partial Aggregation aggregate functions can support partial aggregation. To do this with custom aggregate function as again the documentation says we ...
Alexander Y.'s user avatar
0 votes
1 answer
112 views

In SQL Server 2022, is there an aggregate function for doing a bit-wise OR against a particular column? -- Example table, data and output to show the different flags DECLARE @TEST TABLE (FLAGS TINYINT)...
freefaller's user avatar
  • 20.1k
0 votes
0 answers
102 views

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 ...
K H's user avatar
  • 9
2 votes
2 answers
111 views

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 ...
Татьяна Задорожняя's user avatar
-1 votes
2 answers
192 views

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(...
Neccehh's user avatar
  • 41
1 vote
0 answers
112 views

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 ...
Marc Le Bihan's user avatar
4 votes
5 answers
193 views

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 ...
Rohan Srivastwa's user avatar
1 vote
1 answer
52 views

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(...
Pedro Borges's user avatar
  • 1,791
0 votes
0 answers
94 views

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 ...
Rayne's user avatar
  • 15.2k
1 vote
1 answer
121 views

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 ...
Igor's user avatar
  • 49
0 votes
2 answers
64 views

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 ...
user30387333's user avatar
0 votes
1 answer
84 views

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 ...
Sammy Merk's user avatar
0 votes
0 answers
52 views

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 ...
vbulash's user avatar
  • 395
0 votes
0 answers
16 views

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, ...
Faraday12's user avatar
-1 votes
2 answers
148 views

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 ...
Ondra Žižka's user avatar
-1 votes
1 answer
115 views

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-...
Peter Olson's user avatar
0 votes
1 answer
76 views

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 ...
superkingz's user avatar
1 vote
1 answer
67 views

I have an Employees table with the following structure: ID Name ManagerID Salary 1 Alice NULL 90000 2 Bob 1 80000 3 Charlie 1 85000 4 David 2 75000 5 Eve 2 70000 6 Frank 3 72000 I need a single SQL ...
Safwaa Samin's user avatar
0 votes
1 answer
61 views

I've got this SELECT : SELECT OS.returnmessageid, OS.tagconfig, CASE WHEN OP.messagetype = 202 AND OS.datapointid IN ( 1, 3 ) THEN CONVERT(NVARCHAR(max), ...
Alex Gordon's user avatar
  • 61.5k
2 votes
2 answers
491 views

I have a Postgres query I'm trying to aggregate an array of arrays with different dimensions, a simplified form of the query can be written as: SELECT n, ARRAY(SELECT UNNEST(a) FROM (SELECT ARRAY_AGG(...
Oliver Morgan's user avatar
0 votes
1 answer
100 views

I have 2 queries explain analyze select * from reviews where product_id = 4922 and time > now() - interval '2 month' and explain analyze SELECT max(reviews) FROM reviews WHERE ...
rjpj1998's user avatar
  • 419
0 votes
1 answer
70 views

Can anyone think of a better way to structure a SQL query for this problem? I want to group by account_id and determine whether a type of row exists in the table and just aggregate that to a simple ...
Mike Saull's user avatar
  • 1,447
2 votes
2 answers
118 views

I have 2 tables with a 1-to-many relationship. Table A contains 'OBJECTS' and table B contains 'COMPONENTS' have id's that are related and I wrote a query to gather all OBJECTS from table A and ...
GhostCrab's user avatar
0 votes
1 answer
41 views

it's a bit hard to explain, i dont know how to use a condition in a column-select attribute in a SQL who have group by and aggregat functions... Session DateStart DateEnd TradeID TradeKP 1 2024-12-09 ...
the_driver's user avatar
0 votes
4 answers
96 views

I'm trying to get a ratio of 'Good' values to the Total for a given ID. The query below works when I only use one ID for the IN clause. However when I add more than one ID, the Total ends up being ...
John's user avatar
  • 463
0 votes
1 answer
31 views

I am trying to get the sum of all the counts of this field. SELECT FieldName, COUNT(*) AS count, SUM(COUNT(*)) AS sum FROM TABLE GROUP BY FieldName But when I add the SUM, I get this ...
John's user avatar
  • 463
2 votes
1 answer
158 views

I’m trying to get the first and last login timestamps for each user from a logins table that records a new timestamp each time a user logs in. Here’s the structure of my table: user_id login_timestamp ...
walkingbas's user avatar
0 votes
0 answers
55 views

I was trying to use the aggregate function of the MongoDB Post.findSingleById = function(id) { return new Promise(async (resolve, reject) => { if (typeof(id) !== 'string' || !ObjectId....
HBM Illustration's user avatar
1 vote
1 answer
73 views

Lets say you have some table you're querying percentiles from, with the same grouping used for both columns: SELECT percentile_disc(0.25) WITHIN GROUP (ORDER BY my_col) as p25, percentile_disc(...
ijustlovemath's user avatar
1 vote
0 answers
52 views

the first sql SELECT rtx , arrayJoin(['Istanbul', 'Berlin', 'Bobruisk']) AS city FROM ( SELECT 'hi' as rtx ) where city = 'Istanbul' group by rtx, city; the result is rtx city ...
Yuanchao Hu's user avatar
1 vote
3 answers
103 views

I need to accumulate data in hierarchical query like this: select id, prior id as parent_id, count * prior count --need to be accumulated through whole hierarchy like sys_connect_by_path from ...
Efgrafich's user avatar
2 votes
2 answers
108 views

I have table like create table vals (k, v, z, y, m) AS VALUES (0, 0, 1, 8, 0), (1, 2, 1, 1, 6), (1, 0, 0, 2, 2), (5, 4, 6, 8, 9), (0, 0, 0, 6, 6); I want to calculate modal value for each row. ...
Любовь Пономарева's user avatar
-1 votes
1 answer
61 views

I have a table of operations with dates and quantities. dateTime quantity 2024-01-01 1 2024-02-5 2 I want to sum the quantities for each month and then group by each month, which is working fine. Then ...
John919's user avatar
  • 13
0 votes
1 answer
126 views

I have a website connected to a MySQL database of songs, and am working to improve full-text search on the site. A simple query with MATCH() works as expected, but as soon as I add an aggregate ...
Samuel Bradshaw's user avatar
0 votes
2 answers
305 views

I am migrating some legacy code from an Oracle DB to an SQL Server DB. I have come along this piece of code, with the purpose of calculating the cumulative amount over the last 6 months/ year, for ...
E. Gptreas's user avatar
1 vote
1 answer
102 views

I have the following tables in a Postgres 16.5 database, tracking player completions for levels, with some modifiers: CREATE TABLE levels ( id int PRIMARY KEY , points int NOT NULL ); CREATE TABLE ...
TheSartorsss's user avatar
0 votes
1 answer
125 views

Why is the behaviour of min() different from max()? Select max(My_Date) over (order by My_Date) as Max_Datum , min(My_Date) over (order by My_Date) as Min_Datum From ( Select dateadd(m,-1,...
Merlin Nestler's user avatar
1 vote
1 answer
57 views

I have a table of which looks something like: sport date daily_attempt soccer 11/12/2021 1 soccer 04/09/2023 1 soccer 04/09/2023 2 swimming 07/07/2022 1 swimming 08/08/2024 1 swimming 08/08/2024 2 ...
Luke's user avatar
  • 167
3 votes
1 answer
134 views

Why does the XMLAGG give me a different order than my query even though they have the same ORDER BY? I can't figure out how to get my xml in the same order as my query. I tried using CONVERT(file_name,...
Elie G.'s user avatar
  • 1,784
2 votes
1 answer
41 views

I just found something very strange in the Postgres test suite. -- test for outer-level aggregates -- this should work select ten, sum(distinct four) from onek a group by ten having exists (select 1 ...
Mason Wheeler's user avatar
0 votes
0 answers
482 views

I am trying to create a query where I am filtering out the number of events each day, which is represented by totalCount. Now after that, I am again filtering the number of events based on some ...
Om Kashyap's user avatar
-1 votes
1 answer
41 views

i am using python. i have a dataframe: # Sample DataFrame data = { 'sto_num': [1, 1, 1, 2, 2, 3, 3], 'sto_text': ['ab', 'ab', 'ab', 'k', 'k', 'b', 'b'], 'tu_num': [2.2, 2.6, 3.5, 1.2, 1.3, ...
user24958090's user avatar
0 votes
1 answer
170 views

I’m trying to take the sum of the count of a column and it’s telling me sum is already an aggregate and can not further aggregate. Attempt: Sum(Count of Cases) The count of cases is a calculated file ...
Jesse Y's user avatar
  • 33
2 votes
1 answer
120 views

I have a query that should create a view that will be used to be exported as csv file. Here's the query: CREATE OR REPLACE VIEW coupons_export AS SELECT coupons.code AS coupon, ...
Gregory Farias's user avatar
0 votes
1 answer
80 views

I am trying to create sets from existing rows but having difficulty. I have some success but it is not coming to what I am expecting. Here is my existing data and my desired outcome. I tried many ...
Algoritmi's user avatar
0 votes
1 answer
403 views

I have a table - NS_Data ns tid res nid PQR ITKT20254 not include A PQR ITKT20223 not include A PQR ABCD23456 not include B PQR ABCD54321 not include B PQR ITKT21111 include A I want the output in ...
Prachi's user avatar
  • 45
1 vote
1 answer
299 views

I have the table FruitMarket Fruit Color City apple red Shimala apple Green Shimal apple blue Shimala apple yellow Manali grape black Nagpur grape orange Nashik grape purple Nashik grape white Nagpur ...
Prachi's user avatar
  • 45
5 votes
1 answer
249 views

I have a PostgreSQL query that aggregates data from multiple tables and generates a report. Currently it works perfectly fine and it is quite simple. Here is the query I'm using: SELECT a.name AS ...
vinnylinux's user avatar
  • 7,064

1
2 3 4 5
119