Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
1 answer
111 views

For example, I have this table below, how can I display only the records that aren't in the 10 minutes range. In this example should return the first and last in note examples user_id | ...
Luis's user avatar
  • 2,711
3 votes
3 answers
132 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
4 votes
4 answers
228 views

I need to sort a query's results by two methods at the same time. I want the first 3 records (returned) to be based on their prevalence in another table And then I want the rest of the results sorted ...
Gavin Baumanis'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
0 votes
0 answers
68 views

Windowed aggregate functions on Decimal-types move decimals to integers I found a bug in polars (version 1.21.0 in a Python 3.10.8 environment) using windowed aggregate functions. They are not ...
jpm_phd's user avatar
  • 935
2 votes
2 answers
70 views

I am in a situation where I have a data frame with X and X values as well as two groups GROUP1 and GROUP2. Looping over both of the groups, I want to fit a linear model against the X and Y data and ...
Thomas's user avatar
  • 1,351
1 vote
1 answer
48 views

In quantitative finance, maximum drawdown is a key risk metric that measures the largest decline from a peak to a trough over a period. I want to calculate the maximum drawdown over the past 10 ...
Huang WeiFeng's user avatar
1 vote
1 answer
141 views

I am breaking my head over this probably pretty simply question and I just can't find the answer anywhere. I want to create a new column with a grouped sum of another column, but I want to keep all ...
gernophil's user avatar
  • 637
1 vote
1 answer
78 views

I am learning window functions, primarily with this page of the docs. I am trying to categorize the window functions according to whether they heed window frames, or ignore them and act on the ...
Logan O'Brien's user avatar
1 vote
1 answer
72 views

The goal is to use MEDIAN as a window function with a sliding window of a specific size. SELECT *, MEDIAN(n) OVER(ORDER BY id ROWS BETWEEN 3 PRECEDING AND CURRENT ROW) FROM test_data ORDER BY id;...
Lukasz Szozda's user avatar
2 votes
2 answers
73 views

In a table, I have plan details of customers with their customer_id and enroll_date. Now, I want to identify duplicate and valid enrollments from the overall data. Duplicate: If a customer enrolls a ...
Lakshmi Sruthi K's user avatar
1 vote
1 answer
62 views

CREATE TABLE `messages` ( `ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `Arrival` TIMESTAMP NOT NULL, `SenderID` INT UNSIGNED NOT NULL, -- Fields describing messages skipped PRIMARY ...
Dmitry Vasiliev's user avatar
1 vote
1 answer
85 views

Suppose I have below dataset: date Value 01-Jul-24 37 01-Aug-24 76 01-Sep-24 25 01-Oct-24 85 01-Nov-24 27 01-Dec-24 28 And I want to aggregate by 3 months rolling:...
ccgg's user avatar
  • 13
1 vote
2 answers
168 views

I have a Dataset containing GPS Coordinates of a few planes. I would like to calculate the bearing of each plane at every point in time. The Dataset as among others these columns: event_uid plane_no ...
jimfawkes's user avatar
  • 385
4 votes
1 answer
110 views

Similar question is asked here However it didn't seem to work in my case. I have a dataframe with 3 columns, date, groups, prob. What I want is to create a 3 day rolling mean of the prob column values ...
AColoredReptile's user avatar
1 vote
2 answers
106 views

I have a table data as show below. cust_id city_type city_name start_date 1 physical Las Vegas 5/17/2024 1 office Seattle 5/17/2024 1 office Dallas 9/20/2024 1 physical Dallas 10/30/2024 1 office ...
ragstand's user avatar
0 votes
3 answers
121 views

I have an issue to calculate the max() value over partition by where i want to exclude the current row each time. Assuming I have a table with ID, Group and Valbue. calculating max/min/etc. over ...
Rabers's user avatar
  • 45
8 votes
1 answer
415 views

While preparing an answer to another question here, I coded up a query that contained multiple window functions having the same OVER(...) clause. Results were as expected. select ... sum(sum(s....
T N's user avatar
  • 10.6k
1 vote
1 answer
101 views

I am an SQL server developer working on a project in a PostgreSQL environment. I am having some PostgreSQL syntax issues. I am working off version 9.3. In a given table, I am trying to set every 10 ...
Peter Sun's user avatar
  • 1,943
0 votes
0 answers
16 views

My background is in SQL and I was wondering what was the most efficient/readable way of creating multiple columns using the same window partition within a pandas chain. Suppose I have the following ...
gjk515's user avatar
  • 23
0 votes
1 answer
64 views

In spark SQl, you can write SELECT title, rn, lead(rn, 1) IGNORE NULLS over(order by rn) as next_rn FROM my_table ; How would you add the IGNORE NULLS part in the equivalent Scala code? val ...
M.S.Visser's user avatar
0 votes
3 answers
200 views

Please consider this script: Declare @tbl Table ( F1 int, F2 int, Year int, Month tinyint ) Insert into @tbl values (10, 1, 2020, 1), (10, 1, 2020, 2), (10, 1, 2020, 3), (10, ...
DooDoo's user avatar
  • 13.1k
1 vote
1 answer
104 views

I’m working with a PostgreSQL table that stores metric data for different assets. The table currently has over 1 billion records. Each update will have multiple metrics, e.g., speed, distance, ...
NRaf's user avatar
  • 7,579
1 vote
1 answer
75 views

I have a table like this: demo at db<>fiddle CREATE TABLE test(id, order_id, start, end1, count) AS VALUES (1, 1, '2023-12-19 10:00:00'::timestamp, '2023-12-19 11:00:00'::timestamp, 15), (2, 1, '...
Axel Siebert's user avatar
1 vote
4 answers
117 views

I'm using Postgres and I would like to find missing ranges of dates. I've got this table with these data : create table event_dates(date)AS VALUES('2024-12-09'::date) ...
lcc's user avatar
  • 13

1
2 3 4 5
93