Re: How to truncate? integers

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: How to truncate? integers
Дата
Msg-id 4EC426EB.8000500@pinpointresearch.com
обсуждение исходный текст
Ответ на How to truncate? integers  (Johann Schatzer <schatzer.johann@gmail.com>)
Список pgsql-novice
On 11/16/2011 12:26 PM, Johann Schatzer wrote:
> How can I ~truncate~ integers?
>
>
> this column
>
> 4770
> ...
>
> should give
>
> 4700
> ...
>
> thank you

Oh, you can also use the behavior of integer math:

select (4770/100)*100;
  ?column?
----------
      4700

If you have negative numbers, you need to determine how they should be
truncated. The two methods will behave differently:

select (-4770/100)*100;
  ?column?
----------
     -4700


select floor(-4770*.01)*100;
  ?column?
----------
     -4800

Cheers,
Steve


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

Предыдущее
От: Steve Crawford
Дата:
Сообщение: Re: How to truncate? integers
Следующее
От: Yangyang
Дата:
Сообщение: How can I show more potential query plans, other than the default one?