Re: Query design assistance - getting daily totals

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query design assistance - getting daily totals
Date: 2007-12-12 06:31:42
Message-ID: 20071212063142.GA26523@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

am Wed, dem 12.12.2007, um 10:34:35 +0900 mailte Paul Lambert folgendes:
> I have a table of account balances as at the end of a working day and
> want to from that, calculate daily total figures.
>
> Eg, let's say I have a table structure of:
> year_id integer
> month_id integer
> working_day integer

Why this broken data types? We have date and timestamp[tz].

> I suspect the second option would be more efficient than the first, and
> probably easier to implement since it would be easier to handle
> cross-month boundaries, i.e. day 1's daily total will be the amount on
> that day minus the amount of the final day in the previous month - but
> does anyone have any alternate suggestions that would be better still?

Yes, i would also write a similar function. And if you have proper
datatypes it would be simpler to calculate the previous date and you can
use a proper index on the date column.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Paul Lambert 2007-12-12 06:39:48 Re: Query design assistance - getting daily totals
Previous Message Paul Lambert 2007-12-12 06:30:06 Re: Function result using execute