From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | cgg007(at)yahoo(dot)com, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Elegant SQL solution: |
Date: | 2003-06-08 01:54:30 |
Message-ID: | 200306071854.30499.josh@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
CGG:
> I could create a one-column table with values 1 - 12 in it, and select from
> that table with a where clause matching "month".
This is probably the simplest, most elegant solution. It is also the "most
relational".
> I could also create a view
> "SELECT 1 UNION SELECT 2 UNION ..." and select against the view.
This would be both awkward and have appaling performance.
> There MUST
> be a more elegant way to do this.
Another method would be to write a set returning function that generates the
months and corresponds them to a cursor of the totals and outputs that.
However, I think your first method is likely to be the fastest and easiest to
maintain.
--
Josh Berkus
Aglio Database Solutions
San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | greg | 2003-06-08 01:58:32 | Re: Elegant SQL solution: |
Previous Message | Joe Conway | 2003-06-08 01:03:50 | Re: "Join" on delimeter aggregate query |