转载http://luobeng.blogbus.com/logs/36300419.htmlOracle/PLSQL: Median Function In Oracle/PLSQL, the median function returns the median of an expression.The syntax for the median function is:median( expression ) [ OVER ( query partition clause ) ]For example:select median(salary) from employees where department = 'Marketing';
with tb as ( select '王' name,'数学' course, 88 score, '2011-11-30 18:11:00' time from dual union all select '王1' , '数学', 78, '2011-11-30 18:11:00' from dual union all select '王2' , '数学', 99, '2011-10-30 18:11:00' from dual union all select '张' , '数学', 67, '2011-11-30 18:11:00' from dual ) select median(score) as median from tbMEDIAN ---------------------- 83
In Oracle/PLSQL, the median function returns the median of an expression.The syntax for the median function is:median( expression ) [ OVER ( query partition clause ) ]For example:select median(salary)
from employees
where department = 'Marketing';
select '王' name,'数学' course, 88 score, '2011-11-30 18:11:00' time from dual union all
select '王1' , '数学', 78, '2011-11-30 18:11:00' from dual union all
select '王2' , '数学', 99, '2011-10-30 18:11:00' from dual union all
select '张' , '数学', 67, '2011-11-30 18:11:00' from dual
)
select median(score) as median from tbMEDIAN
----------------------
83