X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4CD5DD1DC7D for ; Tue, 13 Apr 2004 14:49:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 17389-06 for ; Tue, 13 Apr 2004 14:49:24 -0300 (ADT) Received: from web11508.mail.yahoo.com (web11508.mail.yahoo.com [216.136.172.40]) by svr1.postgresql.org (Postfix) with SMTP id 816FFD1BAFC for ; Tue, 13 Apr 2004 14:49:22 -0300 (ADT) Message-ID: <20040413174919.79405.qmail@web11508.mail.yahoo.com> Received: from [65.207.234.18] by web11508.mail.yahoo.com via HTTP; Tue, 13 Apr 2004 10:49:19 PDT Date: Tue, 13 Apr 2004 10:49:19 -0700 (PDT) From: Terry Brick Subject: Re: Formatting Functions and Group By To: Tom Lane Cc: pgsql-sql@postgresql.org In-Reply-To: <24390.1081877598@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/121 X-Sequence-Number: 17496 Thank you both for your responses. That's just what I needed.... and thanks for catching my mistake Tom. And may I say that I am VERY happy to be moving to Postgres. The lack of a native Win32 version was thing only thing holding us back from Postgres previously. I think this is the only kind of query I will have had difficulty porting. I'm looking forward to ditching MySQL and never looking back!! :) --- Tom Lane wrote: > > Ah, good ol' MySQL :-( ... let the user do what he wants whether the > result is well defined or not ... > > I'd suggest doing the grouping/ordering numerically rather than > textually. For instance, > > select > to_char(date_trunc('month', myCol), 'Mon YY') > from > myTable > group by > date_trunc('month', myCol) > order by > date_trunc('month', myCol); > > Now this assumes you really want a time-based ordering, which the quoted > example doesn't give --- you've got month sorting to the left of year, > is that really what you want? If it is then you'd need to go > > group by > date_trunc('month', myCol) > order by > to_char(date_trunc('month', myCol), 'MM YYYY') > > regards, tom lane __________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/