我有一个Vertica表:
my_day, price
'2016-10-01', 55
...
两列都编码为VARCHAR。
我需要找到每天的中位数价格,所以我试过
select distinct my_day, median(cast(price as numeric)) over (partition by my_day)
from schem01.my_test_table
where my_day between '2016-10-01' and '2016-10-10'
group by my_day, cast(price as numeric);
但是,这会返回一个非常高的值,大约是我手动计算和测试的实际中位数的2-3倍。
有人知道这里的中位数是怎么回事吗?