标签:bsp avg end 计算 having sig group by where 查找
问题:计算一列数字值的中间值(中间值就是一组有序元素中间成员的值)。例如,查找DEPTNO 20中工资的中间数。
select avg(sal)
from (
select e.sal
from emp e,emp d
where e.deptno = d.deptno and e.deptno =20
group by e.sal
having sum(case when e.sal=d.sal then 1 ehse 0 end) >=abs(sum(sign(e.sal - d.sal))));
标签:bsp avg end 计算 having sig group by where 查找
原文地址:http://www.cnblogs.com/liang545621/p/6802314.html