Re: Numeric Data Type Rounding Up

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: Numeric Data Type Rounding Up
Дата
Msg-id 4F57988C.1040509@pinpointresearch.com
обсуждение исходный текст
Ответ на Numeric Data Type Rounding Up  (Carlos Mennens <carlos.mennens@gmail.com>)
Список pgsql-novice
On 03/07/2012 08:50 AM, Carlos Mennens wrote:
> I have a table...
>                                  Table "public.weight"
>   Column |         Type          |                      Modifiers
> --------+-----------------------+-----------------------------------------------------
> ...
>   lbs    | numeric(5,0)          | not null
> ...
> Now when I enter a value in the 'lbs' field / column of '172.80', it
> rounds the value up to '173.00'.
You specified a precision of 0. Try 2 (if you really want to track to
the 100th of a pound) or 1 for 1/10 pound. numeric(5,2) will be good up
to 999.99 pounds.

steve=# select 123.45::numeric(5,0);
  numeric
---------
      123

steve=# select 123.45::numeric(5,1);
  numeric
---------
    123.5

steve=# select 123.45::numeric(5,2);
  numeric
---------
   123.45

Cheers,
Steve


В списке pgsql-novice по дате отправления:

Предыдущее
От: Carlos Mennens
Дата:
Сообщение: Re: Numeric Data Type Rounding Up
Следующее
От: Jude Lucien
Дата:
Сообщение: How To Store Large Text Strings