HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Formal name for functions that use the OVER clause

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
theformalclausenameforthatfunctionsuseover

Problem

Is there a formal/academic name for the family of functions in Sql Server like ROW_NUMBER(), LAG, LEAD, RANK etc, that make use of the OVER(ORDER BY ) syntax? How much of this is covered by the ansi standard?

I can see on MSDN that some of those are listed as analytic functions, but others are ranking functions.

I ask using Sql Server names, but one of the reasons I want to know is to help me find out how to translate some of these queries for other databases, and gauge support among those databases. The other reason is to help me wrap my head around the concept more completely. Most of my experience pre-dates their Sql Server use, and I find lately I'm too used to old workarounds when one of these functions might be the easy fit. Knowing how to refer to them will help me when reading other things.

Solution

I believe the term you are looking for is window functions. Most databases have support for these types of functions.

Window functions belong to a type of function known as a ‘set function’, which means a function that applies to a set of rows. The word ‘window’ is used to refer to the set of rows that the function works on.

Windowing functions were added to the standard SQL:2003 that is managed by the ISO and it was specified in more detail in SQL:2008 For some time, other DBMSs such as Oracle, Sybase and DB2 have had support for window functions. Even the open source RDBMS PostgreSQL has a full implementation. SQL Server has had only a partial implementation up to now, but it is coming in SQL 2012.

Source

A window function is one of:

  • A rank function.



  • A distribution function.



  • The row number function.



  • A window aggregate function.



  • The ntile function.



  • The lead function.



  • The lag function.



  • The first-value function.



  • The last-value function.



  • The nth-value function.

Context

StackExchange Database Administrators Q#72765, answer score: 7

Revisions (0)

No revisions yet.