Re: Query design assistance - getting daily totals - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: Query design assistance - getting daily totals
Date
Msg-id 20071212063142.GA26523@a-kretschmer.de
Whole thread Raw
In response to Query design assistance - getting daily totals  (Paul Lambert <paul.lambert@reynolds.com.au>)
Responses Re: Query design assistance - getting daily totals
List 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


pgsql-sql by date:

Previous
From: Paul Lambert
Date:
Subject: Re: Function result using execute
Next
From: Paul Lambert
Date:
Subject: Re: Query design assistance - getting daily totals