Formatting Functions and Group By - Mailing list pgsql-sql

From Terry Brick
Subject Formatting Functions and Group By
Date
Msg-id 20040413161305.22857.qmail@web11502.mail.yahoo.com
Whole thread Raw
Responses Re: Formatting Functions and Group By  (Bruno Wolff III <bruno@wolff.to>)
Re: Formatting Functions and Group By  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Hi,
I'm porting a bunch of queries from MySQL to Postgres 7.4 and am having a problem with one
particular area.  For example, a query like this works in MySQL:

select to_char(myCol,'Mon YY')
from myTable
group by to_char(myCol,'MM YYYY')
order by to_char(myCol,'MM YYYY')

Postgres will give me an error saying that "to_char(myCol,'Mon YY')" must be in the 'group by'.  I
understand why that normally needs to be the case, but in theory, it would be ok here because they
are actually the same values (in the select and group by) but just formatted differently.  I just
want the query to be grouped and ordered by month and year, but to be formatted differently in the
output.  

Any ideas?

Thanks!!

    
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: trigger/for key help
Next
From: Bruno Wolff III
Date:
Subject: Re: Formatting Functions and Group By