Elegant SQL solution:

Поиск
Список
Период
Сортировка
От Chris Gamache
Тема Elegant SQL solution:
Дата
Msg-id 20030606162635.97132.qmail@web13807.mail.yahoo.com
обсуждение исходный текст
Ответ на Re: simulating partial fkeys..  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: Elegant SQL solution:  (greg@turnstep.com)
Re: Elegant SQL solution:  (Josh Berkus <josh@agliodbs.com>)
Re: Elegant SQL solution:  (Ian Barwick <barwick@gmx.net>)
Список pgsql-sql
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     | 2343     | 9984     | 4035     | 25210    | 64312    | 933

I would like:
month | rows
-------+------1     | 2342     | 03     | 9984     | 4035     | 2526     | 07     | 08     | 09     | 010    | 64311
|012    | 933
 


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 elegant way to do this.

Any thoughts?


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com


В списке pgsql-sql по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: simulating partial fkeys.. [ATTN Developers please]
Следующее
От: "David Olbersen"
Дата:
Сообщение: (long) What's the problem?