Re: How to trim values?

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: How to trim values?
Дата
Msg-id 200012282245.eBSMjpH02050@linda.lfix.co.uk
обсуждение исходный текст
Ответ на How to trim values?  (jkakar@expressus.com)
Ответы Re: How to trim values?  (Karel Zak <zakkr@zf.jcu.cz>)
Список 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 по дате отправления:

Предыдущее
От: Webb Sprague
Дата:
Сообщение: Simultaneous Connection Problem
Следующее
От: Thomas SMETS
Дата:
Сообщение: Looking for comments