Re: Aggregate query for multiple records - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Aggregate query for multiple records
Date
Msg-id 200408271319.41343.josh@agliodbs.com
Whole thread Raw
In response to Aggregate query for multiple records  (Scott Gerhardt <scott@g-it.ca>)
List 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


pgsql-sql by date:

Previous
From: Kenneth Gonsalves
Date:
Subject: Re: backup of a specific schema
Next
From: Gaetano Mendola
Date:
Subject: Re: backup of a specific schema