PostgreSQL want to round percentile_cont

488 views Asked by At

I am computing a range of values in PostgreSQL, and I want to round some of them to 2 decimal places. when I do round the average it works round(avg(rate), 2) as avg_rate. when I round the median round(percentile_cont(0.5) within group (order by rate) as med, it gives an error saying I need to add explicit type casts. the percentile_cont works fine without the round, but I am unsure how to fix this. any help would be appreciated. thanks

1

There are 1 answers

0
LukStorms On

Type casting it to decimal will also round the median

percentile_cont(0.5) within group (order by rate)::decimal(8,2) as median