query; check for zero and floats

Поиск
Список
Период
Сортировка
От vince@weaktight.com
Тема query; check for zero and floats
Дата
Msg-id 20060401010317.tbza82opw0c0ccg0@webmail.weaktight.com
обсуждение исходный текст
Ответы Re: query; check for zero and floats  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: query; check for zero and floats  (Joe Conway <mail@joeconway.com>)
Список pgsql-sql
I'm trying to do a simple query and I'm not sure how to get it to work:

SELECT SUM(x0 + y0 + z0) / SUM(x2 + y2) AS A1, SUM(x1 + y1 + z1) / SUM(x3 + y3)
AS A2
FROM test

Problems:

1. All variables are integers.  When it does the division, it returns an
integer, but I want a float.  (I've tried numerous things to no avail)

2. If SUM(x2 + y2) == 0; there is a divide by zero error.  How do I check and
pass on zeroes?

Thanks,
Vince.



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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: have you feel anything when you read this ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: query; check for zero and floats