0

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

gjc
  • 29
  • 3

1 Answers1

1

Type casting it to decimal will also round the median

percentile_cont(0.5) within group (order by rate)::decimal(8,2) as median
LukStorms
  • 28,916
  • 5
  • 31
  • 45