Re: Simple sql question

Поиск
Список
Период
Сортировка
От Wright, George
Тема Re: Simple sql question
Дата
Msg-id 51548D6D5BEB57468163194A8C1A0E983193FC@MAGPTCPEXC02.na.mag-ias.net
обсуждение исходный текст
Ответ на Simple sql question  ("Tore Lukashaugen" <tore@lukashaugen.freeserve.co.uk>)
Ответы Re: Simple sql question
Список pgsql-novice
select cast (col1 as float) / cast (col2 as float) from test;

gives 0.5


-----Original Message-----
From: pgsql-novice-owner@postgresql.org
[mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Tore Lukashaugen
Sent: Wednesday, October 03, 2007 2:02 PM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] Simple sql question

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?

Appreciate your help.

Tore



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly

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

Предыдущее
От: Sean Davis
Дата:
Сообщение: Re: Simple sql question
Следующее
От: Brian Hurt
Дата:
Сообщение: Re: Simple sql question