How to round an average to 2 decimal places in PostgreSQL?

后端 未结 8 1520
渐次进展
渐次进展 2020-11-30 18:01

I am using PostgreSQL via the Ruby gem \'sequel\'.

I\'m trying to round to two decimal places.

Here\'s my code:

SELECT ROUND(AVG(some_column)         


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 18:15

    select ROUND(SUM(amount)::numeric, 2) as total_amount FROM transactions

    gives: 200234.08

提交回复
热议问题