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