PL/SQL 查询函数
求教各位大虾:我想在一张表中找到某一列上所有行记录的中位值,或者是所有行记录中95%的行值是多大,其实就是用来剔除表中某些行出现的异常值,但是我不知道这个异常值是多大。
------解决方案--------------------转载http://luobeng.blogbus.com/logs/36300419.html
Oracle/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 tb
MEDIAN
----------------------
83