Question : I am having trouble wrapping my head around a query that gives me these results I have a […]
Tag: window-functions
Row by row subtraction with single input number
Question : I want to subrtact dynamically from previous row subtraction result and as input i want to give a […]
Is it possible to use LAG() with WHERE?
Question : We are creating a warehouse system. In this system, we will have a Extract page (I don’t know […]
Compare running / cumulative total with static target
Question : I have some daily data and monthly data. I want to compare these two datasets, with Hive and […]
“Ranking” values in an ORDER BY clause?
Question : I have the following table: Table “public.employee_employee” Column | Type | Modifiers —————–+———————–+—————————————————————- id | integer | not […]
Time-series window query for calculating rolling average across group by subquery is inaccurate due to missing rows
Question : I’m trying to generate a rolling average based on a generated time series joined with a subquery on […]
Using activity over last few days to label user as “active”
Question : Here’s an example dataset. with activity_cte (day, user_id, act1, act2) as ( values (‘2020-01-01’::date, 1, 0, 1), (‘2020-01-01’::date, […]
T-SQL to Group time interval change by date range in sql server
Question : The original table has the column Timestamp with Interval Interval: difference in minute between the current and previous […]
Get rows grouped by a foreign key with count of consecutive values
Question : I have a SQL Server database with a transactions table with client_id, date, and is_cancelled. I’m trying to […]
Why is my SQL Server query behaving differently on UPDATE than on SELECT?
Question : I’ve written a SQL Server query that updates records to have a sequential number after partitioning on a […]