Re: One more question about intervals

Поиск
Список
Период
Сортировка
От Konstantinos Agouros
Тема Re: One more question about intervals
Дата
Msg-id 20011104204042.A27702@rumba.agouros.de
обсуждение исходный текст
Ответ на Re: One more question about intervals  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
Ответы Re: One more question about intervals  ("Command Prompt, Inc." <pgsql-general@commandprompt.com>)
Список pgsql-general
On Sun, Nov 04, 2001 at 11:24:10AM -0800, Command Prompt, Inc. wrote:
> 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. ;)
Actually what I would need is date_part(EPOCH) since then I am sure that it is
the seconds and I have to multiply with EURO/3600. The extract-stuff would
ignore minutes or I would have to add these also. The problem is I have to
reconstruct the hours in the format by hand and it would be nice to have the
database do this by itself \:)

Konstantin
>
> 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
>

--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not survive the forming of the cosmos." B'Elana Torres

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

Предыдущее
От: "Command Prompt, Inc."
Дата:
Сообщение: Re: One more question about intervals
Следующее
От: Jakub Ouhrabka
Дата:
Сообщение: foreign keys and deadlock