Re: Aggregate query for multiple records

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Scott Gerhardt <scott(at)g-it(dot)ca>
Cc: psql-sql(at)postgresql(dot)org
Subject: Re: Aggregate query for multiple records
Date: 2004-08-27 20:19:41
Message-ID: 200408271319.41343.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Scott,

> Unfortunately, your revised query works like a charm except for the
> fact that prd_data."date" - prd2."date" + 1 give incorrect values when
> the year wraps, see in the output below. Need to conditionally
> subtract 88 from the date or use an incrementing count() function
> instead of date math to get the correct values.

Oh, that column is text, not a serial number. Well, it's your fault for
using wierd custom data types; you figure it out.

> I'm also wondering if using the date functions of Postgres would be
> helpful since the date column does have the YYYY-year and MM-month
> parts.

Well, you'd want to convert the column to a timestamp, and then you could
compute months. Or you could break it in seperate integer "year" and
"month" columns and do the same thing.

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gregory S. Williamson 2004-08-27 20:29:52 Re: Copy command freezes but INSERT works fine with trigger oninsert.
Previous Message Artimenko Igor 2004-08-27 20:16:14 Copy command freezes but INSERT works fine with trigger on insert.