Re: Simple sql question

Поиск
Список
Период
Сортировка
От Sean Davis
Тема Re: Simple sql question
Дата
Msg-id 4703E1A0.6080801@mail.nih.gov
обсуждение исходный текст
Ответ на Simple sql question  ("Tore Lukashaugen" <tore@lukashaugen.freeserve.co.uk>)
Список pgsql-novice
Tore Lukashaugen wrote:
> Hello,
>
> I am new to Postgres and have an embarassingly simple question. I am running
> v8.2 on Windows Vista although I don't think that has any bearing on the
> answer.
>
> create table test (col1 int, col2 int)
> insert into test values (1,2);
> select col1/col2 from test....yields 0 not 0.5 - why?
>
> Presumably this is because both col1 and col2 are ints and the output needs
> to be casted somehow? Or is it because PGAdmin's SQL interface does not by
> default show the decimal places of output?

Cast one of the values to float first.  Then, your result will be as
expected.

Sean

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

Предыдущее
От: "Tore Lukashaugen"
Дата:
Сообщение: Simple sql question
Следующее
От: "Wright, George"
Дата:
Сообщение: Re: Simple sql question