H2 supports custom aggregate functions.
Do you have a (real-world) use case for MEDIAN?
Regards,
Thomas
I have added the request for MEDIAN to the roadmap. By the way, a
sample implementation (using a user defined aggregate function) is
available here:
Regards,
Thomas
Th2omas!
I will have a good use of that!
Thank You!
SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary; This is just another way to say SELECT e1.*, e2.avg FROM empsalary e1 JOIN ( SELECT depname, AVG(salary) as avg FROM empsalary GROUP BY depname ) e2 ON e1.depname = e2.depname
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
These window functions seem to me like just a shorthand notation.
Here is an example from postgresql documentation.
http://www.postgresql.org/docs/9.1/static/tutorial-window.html
SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary; This is just another way to say SELECT e1.*, e2.avg FROM empsalary e1 JOIN ( SELECT depname, AVG(salary) as avg FROM empsalary GROUP BY depname ) e2 ON e1.depname = e2.depname
SELECT MEDIAN(salary) FROM empsalary;
is just a shorthand for
SELECT salary
FROM empsalary
ORDER BY salary
LIMIT 1 OFFSET SELECT (COUNT(salary)+1)/2 FROM empsalary;