Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 525
Patrick Avatar asked Dec 21 '22 08:12

Patrick


1 Answers

Try this it is working for me

 SELECT round( CAST("NUM" as numeric), 2) FROM ABC;
like image 197
PSR Avatar answered Dec 28 '22 06:12

PSR