Simple math statement - problem

Поиск
Список
Период
Сортировка
От Postgres User
Тема Simple math statement - problem
Дата
Msg-id b88c3460711292122v42d53b24ua17d0cf2afb19145@mail.gmail.com
обсуждение исходный текст
Ответы Re: Simple math statement - problem
Список pgsql-general
I have a large function that's doing a number of calcs.  The final
return value is wrong for a simple reason:  any division statement
where the numerator is less than the denominator is returning a zero.

Each of these statements return a 0, even when properly cast:

select 1/100
select Cast(1 / 100 As decimal)
select Cast(1 / 100 As numeric(6,2))

How can I write statements that returns a decimal?


The problem doesn't appear to be that Postgres won't return decimal
values, as these statements return the correct value:

select .01
select Cast(.01 As decimal)

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

Предыдущее
От: Wes
Дата:
Сообщение: Re: Linux v.s. Mac OS-X Performance
Следующее
От: Ow Mun Heng
Дата:
Сообщение: Re: Simple math statement - problem