Archive for March 10th, 2009
Analytic functions: FIRST_VALUE, LAST_VALUE, LEAD, LAG
In the previous articles I wrote about emulating some of the analytic functions in MySQL.
Today, I'll write about four more userful functions: FIRST_VALUE
, LAST_VALUE
, LEAD
and LAG
.
These functions also do not have aggregate analogs.
FIRST VALUE(column)
returns the value of column from the first row of the grouping set.
LAST_VALUE(column)
returns the value of column from the last row of the grouping set.
This can be illustrated by the following query:
Read the rest of this entry »