Page 1 of 1

SQL median function

Posted: Wed Apr 20, 2016 10:12 pm
by usli06
Is there a SQL function to calculate the median of a number set?

Re: SQL median function

Posted: Thu Apr 21, 2016 2:41 am
by JimKnicely
There is!

In my favorite Vertica client tool vsql, you can use a wild card search to find a function using the \df meta-command:

Code: Select all

dbadmin=> \df *median*
                         List of functions
 procedure_name | procedure_return_type  | procedure_argument_types
----------------+------------------------+--------------------------
 median         | Float                  | Float
 median         | Float                  | Integer
 median         | Float                  | Numeric
 median         | Interval Day to Second | Interval Day to Second
 median         | Interval Year to Month | Interval Year to Month
(5 rows)