Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 337312E0068 for ; Wed, 12 Dec 2007 15:53:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 39777-04 for ; Wed, 12 Dec 2007 15:52:58 -0400 (AST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.246]) by postgresql.org (Postfix) with ESMTP id 4556C2E005D for ; Wed, 12 Dec 2007 15:53:10 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c36so100195ana.33 for ; Wed, 12 Dec 2007 11:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=rYB1dlBfQJ4tOcRRMyqFx299vlcz8+JAvmDb5ADvvBg=; b=ZNxfpUDp+RvMB14pWZ1gjHaOkUj7nkVSmLUGICPVCzQvY1WetZm3GrGsXDaGG8IPdgPYtKRUWeTTcjmaRB4A4ivPTnhOD0xrHbZP/4U8Dtu2X2KLbkPaCvNYko3RVGGfnReXTSnfwulm7jgATPzIoP6u2pcKyabqqwU1MPf/iSs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SrVnHdtZbpgN0rSo9SjK0LwJJltDyXVg2XRM5DRia0fZgkduro84WHNRxmVaP/dXg3TJxlz/5S0UkCatEdCeSSizDVrfPodGsxXnTDBY58+oQqLlb8limV/yHByKOPIVOSgw4fhYfRfx5NVCodUuNLB5uSavbHl7cN4nBJxlVJU= Received: by 10.100.171.10 with SMTP id t10mr2272508ane.65.1197489188266; Wed, 12 Dec 2007 11:53:08 -0800 (PST) Received: by 10.100.34.6 with HTTP; Wed, 12 Dec 2007 11:53:08 -0800 (PST) Message-ID: Date: Wed, 12 Dec 2007 14:53:08 -0500 From: "=?UTF-8?Q?Rodrigo_De_Le=C3=B3n?=" To: "Paul Lambert" Subject: Re: Query design assistance - getting daily totals Cc: pgsql-sql@postgresql.org In-Reply-To: <475F8234.5090907@reynolds.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <475F3AAB.2050609@reynolds.com.au> <20071212063142.GA26523@a-kretschmer.de> <475F8234.5090907@reynolds.com.au> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/73 X-Sequence-Number: 29765 On Dec 12, 2007 1:39 AM, Paul Lambert wrote: > It's a financial application which needs to work using a concept of > 'financial periods' which may not necessarily correspond to calendar > months and it's much easier to manage in this way than it is to merge it > all together using a date field. Eg, 1st January may actually be the > 15th 'working day' of the 9th 'financial period' - however looking at > just a date of jan-1 there is no way of knowing this and it's the > periods that matter more so than the actual date. I think what you need is a Calendar Table to "map" actual dates to "buckets" e.g. 'financial periods', etc. See: http://codeinet.blogspot.com/2006/08/auxiliary-calendar-table-for-sql.html