From: Josh Berkus <josh@agliodbs.com>
To: cgg007@yahoo.com
To: pgsql-sql@postgresql.org
Subject: Re: Elegant SQL solution:
Date: Sat, 7 Jun 2003 18:54:30 -0700
Message-ID: <200306071854.30499.josh@agliodbs.com> (raw)
In-Reply-To: <20030606162635.97132.qmail@web13807.mail.yahoo.com>
References: <20030606162635.97132.qmail@web13807.mail.yahoo.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, cgg007@yahoo.com
Subject: Re: Elegant SQL solution:
In-Reply-To: <200306071854.30499.josh@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox