Re: How to trim values? - Mailing list pgsql-sql

From Oliver Elphick
Subject Re: How to trim values?
Date
Msg-id 200012282245.eBSMjpH02050@linda.lfix.co.uk
Whole thread Raw
In response to How to trim values?  (jkakar@expressus.com)
Responses Re: How to trim values?
List pgsql-sql
jkakar@expressus.com wrote: >Hi, > >I'm trying to figure out how to take a value like 3.68009074974387 >(that is
calculatedfrom values in my database) and have PostgreSQL >hand me 3.68.  Any suggestions would be appreciated.
 

cast it to numeric(x,2)

(where x is the total number of digits, and 2 is two decimal places).

template1=# select  3.68009074974387::numeric(3,2);?column? 
----------    3.68
(1 row)

or use round(value,2)


template1=# select round(3.68009074974387, 2);round 
------- 3.68
(1 row)

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
========================================   "For God shall bring every work into judgment,      with every secret thing,
whetherit be good, or       whether it be evil."               Ecclesiastes 12:14 
 




pgsql-sql by date:

Previous
From: Webb Sprague
Date:
Subject: Simultaneous Connection Problem
Next
From: Thomas SMETS
Date:
Subject: Looking for comments