Top "Window-functions" questions

A window function is a type of SQL operation that aggregates over a partition of the result set.

SQL Server: Difference between PARTITION BY and GROUP BY

I've been using GROUP BY for all types of aggregate queries over the years. Recently, I've been reverse-engineering some code …

sql-server tsql aggregate-functions window-functions
What's the difference between RANK() and DENSE_RANK() functions in oracle?

What's the difference between RANK() and DENSE_RANK() functions? How to find out nth salary in the following emptbl table? …

sql oracle window-functions
Oracle "Partition By" Keyword

Can someone please explain what the partition by keyword does and give a simple example of it in action, as …

sql oracle window-functions
Select Row number in postgres

How to select row number in postgres. I tried this: select row_number() over (ORDER BY cgcode_odc_mapping_id)…

sql postgresql window-functions
Pandas get topmost n records within each group

Suppose I have pandas DataFrame like this: >>> df = pd.DataFrame({'id':[1,1,1,2,2,2,2,3,4],'value':[1,2,3,1,2,3,4,1,1]}) >>> df id …

python pandas greatest-n-per-group window-functions top-n
OVER clause in Oracle

What is the meaning of the OVER clause in Oracle?

sql oracle window-functions
What is ROWS UNBOUNDED PRECEDING used for in Teradata?

I am just starting on Teradata and I have come across an Ordered Analytical Function called "Rows unbounded preceding" in …

sql teradata window-functions
PostgreSQL unnest() with element number

When I have a column with separated values, I can use the unnest() function: myTable id | elements ---+------------ 1 |ab,…

sql arrays postgresql window-functions set-returning-functions
How to use ROW_NUMBER() in UPDATE clause?

ROW_NUMBER() is only for used in the SELECT clause in MS SQL Server, but I want to use it …

sql-server tsql sql-server-2008-r2 window-functions
Calculating Cumulative Sum in PostgreSQL

I want to find the cumulative or running amount of field and insert it from staging to table. My staging …

sql postgresql window-functions analytic-functions cumulative-sum