On Friday 06 June 2003 18:26, Chris Gamache wrote:
> I could create a one-column table with values 1 - 12 in it, and select from
> that table with a where clause matching "month". I could also create a view
> "SELECT 1 UNION SELECT 2 UNION ..." and select against the view. There MUST
> be a more e
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
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
> SELECT date_part('month',rowdate) as month, count(*) as rows FROM mytable GROUP
> BY month;
>...
> I could create a one-column table with values 1 - 12 in it, and select from
> that table with a where clause matching "month". I could also create a
There are so many (bad) ways to skin this cat... I'm looking for a more elegant
solution.
If I
SELECT date_part('month',rowdate) as month, count(*) as rows FROM mytable GROUP
BY month;
It might only return
month | rows
---+--
1 | 234
3 | 998
4 | 403
5 | 252
10|