Re: One more question about intervals

From: "Command Prompt, Inc(dot)" <pgsql-general(at)commandprompt(dot)com>
To: Konstantinos Agouros <elwood(at)agouros(dot)de>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: One more question about intervals
Date: 2001-11-04 19:24:10
Message-ID: Pine.LNX.4.30.0111041118300.19169-100000@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)commandprompt(dot)com
by way of pgsql-general(at)commandprompt(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Konstantinos Agouros 2001-11-04 19:40:42 Re: One more question about intervals
Previous Message Command Prompt, Inc. 2001-11-04 18:54:33 Re: One more question about intervals