pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Terry Brick <terry_brick2000@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Formatting Functions and Group By
Date: Tue, 13 Apr 2004 09:13:05 -0700 (PDT)
Message-ID: <20040413161305.22857.qmail@web11502.mail.yahoo.com> (raw)

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/



view thread (4+ messages)  latest in thread

Message-ID: <20040413161305.22857.qmail@web11502.mail.yahoo.com>
Permalink:  ../20040413161305.22857.qmail@web11502.mail.yahoo.com/
Also on:    postgresql.org/message-id/20040413161305.22857.qmail@web11502.mail.yahoo.com

 · 

reply

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: terry_brick2000@yahoo.com
  Subject: Re: Formatting Functions and Group By
  In-Reply-To: <20040413161305.22857.qmail@web11502.mail.yahoo.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