Search code examples
sqldatabasepostgresqlrdbms

round off column value in postgresql


I'm trying to round off column value with 2 decimal places.

create table ABC("NUM" real);----------created table

insert into ABC values(22.567333335555555); ---------inserted values

however I tried this query

select ROUND("NUM:,2) from ABC;

And getting the below Error message

ERROR:  function round(real, integer) does not exist
LINE 1:  select ROUND("NUM",2) from ABC;

I want to display the Answer should be two decimal value like as

NUM
-----
22.56

Solution

  • Try this it is working for me

     SELECT round( CAST("NUM" as numeric), 2) FROM ABC;