- 利用HAVING子句求中位数(收入的中位)
select T1.income from graduates T1,graduates T2
group by T1.income
having sum(case when T2.income >= T1.income then 1 else 0 end) >= count(*)/2
and sum(case when T2.income <= T1.income then 1 else 0 end) >= count(*)/2
- 当数据条数是奇数时
| income |
| 17500.000 |
- 当数据条数是偶数时
| income |
| 15000 |
| 20000 |

1672

被折叠的 条评论
为什么被折叠?



