Re: One more question about intervals - Mailing list pgsql-general

From Command Prompt, Inc.
Subject Re: One more question about intervals
Date
Msg-id Pine.LNX.4.30.0111041118300.19169-100000@commandprompt.com
Whole thread Raw
In response to Re: One more question about intervals  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
Responses Re: One more question about intervals  (Konstantinos Agouros <elwood@agouros.de>)
List 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 by date:

Previous
From: "Command Prompt, Inc."
Date:
Subject: Re: One more question about intervals
Next
From: Konstantinos Agouros
Date:
Subject: Re: One more question about intervals