pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
SELECT DISTINCT ... ORDER BY UPPER(column_name) fails 2+ messages / 2 participants [nested] [flat]
* SELECT DISTINCT ... ORDER BY UPPER(column_name) fails @ 2007-11-04 16:49 Aymeric Levaux <aymeric@javablackbelt.com> 0 siblings, 1 reply; 2+ messages in thread From: Aymeric Levaux @ 2007-11-04 16:49 UTC (permalink / raw) To: pgsql-sql On pgsql 8.2, if you do the following query, everything is fine: SELECT DISTINCT tag FROM logs ORDER BY tag; But if you'd like to do a case insensitive order by like this: SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag); or SELECT DISTINCT tag FROM logs ORDER BY LOWER(tag); You get the following error message : for SELECT DISTINCT, ORDER BY expressions must appear in select list. It is weird as the order by column appears in the select. Any thoughts? -- Aymeric Levaux <http://www.javablackbelt.com; ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: SELECT DISTINCT ... ORDER BY UPPER(column_name) fails @ 2007-11-04 17:12 Tom Lane <tgl@sss.pgh.pa.us> parent: Aymeric Levaux <aymeric@javablackbelt.com> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2007-11-04 17:12 UTC (permalink / raw) To: aymeric@javablackbelt.com; +Cc: pgsql-sql Aymeric Levaux <aymeric@javablackbelt.com> writes: > SELECT DISTINCT tag FROM logs ORDER BY UPPER(tag); > You get the following error message : > for SELECT DISTINCT, ORDER BY expressions must appear in select list. > It is weird as the order by column appears in the select. No it doesn't. The ORDER BY expression is "UPPER(tag)" not just "tag". regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-11-04 17:12 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2007-11-04 16:49 SELECT DISTINCT ... ORDER BY UPPER(column_name) fails Aymeric Levaux <aymeric@javablackbelt.com> 2007-11-04 17:12 ` Tom Lane <tgl@sss.pgh.pa.us>
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