Reputation: 39
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
Upvotes: 1
Views: 669
Reputation: 29647
Type casting it to decimal will also round the median
percentile_cont(0.5) within group (order by rate)::decimal(8,2) as median
Upvotes: 2