Re: One more question about intervals

Поиск
Список
Период
Сортировка
От Command Prompt, Inc.
Тема Re: One more question about intervals
Дата
Msg-id Pine.LNX.4.30.0111041118300.19169-100000@commandprompt.com
обсуждение исходный текст
Ответ на Re: One more question about intervals  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
Ответы Re: One more question about intervals  (Konstantinos Agouros <elwood@agouros.de>)
Список pgsql-general
On Sun, 4 Nov 2001, Command Prompt, Inc. wrote:
>Couldn't you just multiply your cumulative hours by the cost? E.g.:
>
>lx=# SELECT extract(DAYS FROM sum(i)) * 24 +
>lx-#        extract(HOURS FROM sum(i)) * 100 || ' Euros' AS cost
>lx-#        FROM my_intervals;
>   cost
>-----------
> 372 Euros
>(1 row)

Whoops! I just noticed I messed up my operator precedence there in my
example. ;)

It should've read like this:

lx=# SELECT (extract(DAYS FROM sum(i)) * 24 +
lx(#         extract(HOURS FROM sum(i))) * 100 || ' Euros' AS cost
lx-#        FROM my_intervals;
    cost
------------
 7500 Euros
(1 row)

The point's the same, just make sure you group the time units in
parentheses before multiplying against a currency rate (unless you want to
severely undercharge). ;)


Regards,
Jw.
--
jlx@commandprompt.com
by way of pgsql-general@commandprompt.com


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

Предыдущее
От: "Command Prompt, Inc."
Дата:
Сообщение: Re: One more question about intervals
Следующее
От: Konstantinos Agouros
Дата:
Сообщение: Re: One more question about intervals