要计算偶数行的中位数,我知道我必须将RowNum除以2。我不明白为什么我需要在“ WHERE RowNum IN((RowCnt +1 )/ 2,(RowCnt + 2 )/ 2)”。我不能只写“在((RowCnt)/ 2,(RowCnt)/ 2)中的RowNum中”)吗?
with t1 as
(select *,
row_number() over(order by hourly_pay) as RowNum,
count(*) over() as RowCnt
from employee_data)
select *
from t1
WHERE RowNum IN ((RowCnt + 1) / 2, (RowCnt + 2) / 2)
我的视频解释了我的困惑:https://streamable.com/mv2vj