以Oracle範例資料庫中的employees資料表為例,計算每個部門的箱型圖數值:
select department_id, max(salary) Upper_whisker, min(salary) Lower_whisker, round(avg(salary),3) Average, PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY salary ASC) Q1, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary ASC) Median, PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY salary ASC) Q3 from employees t group by department_id