Archive for March 8th, 2009
In one of the previous articles I wrote about emulating some of analytic functions in MySQL.
Now, I’d like to cover this question more extensively.
A quick reminder: an analytic function is a function that behaves like an aggregate function with one exception: aggregate function returns one last row for each aggregated set, while an analytic function returns intermediate results too.
An analytic function can be made out of almost all aggregate functions by adding keyword
OVER to them with two additional clauses:
PARTITION BY and
PARTITION BY is analog of
ORDER BY defines order in which the intermediate rows will be evaluated.
The behaviour of analytic functions can probably be best illustrated with an example:
Read the rest of this entry »