pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
COALESCE in ORDER BY...
4+ messages / 3 participants
[nested] [flat]

* COALESCE in ORDER BY...
@ 2003-05-17 16:40 Terry Yapt <pgsql@technovell.com>
  2003-05-17 17:14 ` Re: COALESCE in ORDER BY... Andreas Schmitz <andreas.schmitz@as-dataservice.de>
  0 siblings, 1 reply; 4+ messages in thread

From: Terry Yapt @ 2003-05-17 16:40 UTC (permalink / raw)
  To: pgsql-sql

Why this doesn't run on postrgreSQL 7.3.1 ?

www=> SELECT 10 AS first ORDER BY first DESC;                            
 first
-------
    10
(1 row)

www=> SELECT 10 AS first ORDER BY COALESCE(first,0) DESC;
ERROR:  Attribute "first" not found

Thanks in advance..




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: COALESCE in ORDER BY...
  2003-05-17 16:40 COALESCE in ORDER BY... Terry Yapt <pgsql@technovell.com>
@ 2003-05-17 17:14 ` Andreas Schmitz <andreas.schmitz@as-dataservice.de>
  2003-05-17 17:41   ` Re: COALESCE in ORDER BY... Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Andreas Schmitz @ 2003-05-17 17:14 UTC (permalink / raw)
  To: Terry Yapt <pgsql@technovell.com>; +Cc: pgsql-sql

Terry Yapt wrote:

>www=> SELECT 10 AS first ORDER BY COALESCE(first,0) DESC;
>ERROR:  Attribute "first" not found
>
>Thanks in advance..
>  
>
Perhaps, this is a bug, but I have a workarround for you till this is 
clariefied:

SELECT *
FROM (SELECT 10 AS FIRST) AS vtbl
ORDER BY COALESCE(vtbl.first,0) DESC;

(Tested with 7.3.2)

Best regards
-- 
Andreas Schmitz
AS-DataService <http://www.as-dataservice.de;
Kastanienallee 24
D-54662 Speicher

Tel.: (0 65 62) 93 05 17
Fax: (0 65 62) 93 05 18
Email: andreas.schmitz@as-dataservice.de 
<mailto:andreas.schmitz@as-dataservice.de>

Ust-IdNr.: DE211466407
Handelsregister: HRA 1869 - Amtsgericht Bitburg
<http://www.as-dataservice.de;

 




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: COALESCE in ORDER BY...
  2003-05-17 16:40 COALESCE in ORDER BY... Terry Yapt <pgsql@technovell.com>
  2003-05-17 17:14 ` Re: COALESCE in ORDER BY... Andreas Schmitz <andreas.schmitz@as-dataservice.de>
@ 2003-05-17 17:41   ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Stephan Szabo @ 2003-05-17 17:41 UTC (permalink / raw)
  To: Andreas Schmitz <andreas.schmitz@as-dataservice.de>; +Cc: Terry Yapt <pgsql@technovell.com>; pgsql-sql


On Sat, 17 May 2003, Andreas Schmitz wrote:

> Terry Yapt wrote:
>
> >www=> SELECT 10 AS first ORDER BY COALESCE(first,0) DESC;
> >ERROR:  Attribute "first" not found
> >
> >Thanks in advance..
> >
> >
> Perhaps, this is a bug, but I have a workarround for you till this is
> clariefied:

Just an unimplemented enhancement I think.  At least in SQL92, order
by expressions need to be column references (possibly with collation
conversions), we allow some functional order by expressions, but not one's
referencing select aliases I think.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: COALESCE in ORDER BY...
@ 2003-05-18 11:27 Terry Yapt <pgsql@technovell.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Terry Yapt @ 2003-05-18 11:27 UTC (permalink / raw)
  To: andreas.schmitz@as-dataservice.de; +Cc: pgsql-sql

Ok Thanks Andreas, but It was only curiosity because in Oracle I usually use this kind of ORDER BY on SQL's.

Thanks...

-----Original Message-----
From: Andreas Schmitz <andreas.schmitz@as-dataservice.de>
To: Terry Yapt <pgsql@technovell.com>
Date: Sat, 17 May 2003 19:14:09 +0200
Subject: Re: [SQL] COALESCE in ORDER BY...

Terry Yapt wrote:

>www=> SELECT 10 AS first ORDER BY COALESCE(first,0) DESC;
>ERROR:  Attribute "first" not found
>
>Thanks in advance..
>  
>
Perhaps, this is a bug, but I have a workarround for you till this is 
clariefied:

SELECT *
FROM (SELECT 10 AS FIRST) AS vtbl
ORDER BY COALESCE(vtbl.first,0) DESC;

(Tested with 7.3.2)

Best regards
-- 
Andreas Schmitz
AS-DataService <http://www.as-dataservice.de;
Kastanienallee 24
D-54662 Speicher

Tel.: (0 65 62) 93 05 17
Fax: (0 65 62) 93 05 18
Email: andreas.schmitz@as-dataservice.de 
<mailto:andreas.schmitz@as-dataservice.de>

Ust-IdNr.: DE211466407
Handelsregister: HRA 1869 - Amtsgericht Bitburg
<http://www.as-dataservice.de;









^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-05-18 11:27 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-17 16:40 COALESCE in ORDER BY... Terry Yapt <pgsql@technovell.com>
2003-05-17 17:14 ` Andreas Schmitz <andreas.schmitz@as-dataservice.de>
2003-05-17 17:41   ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-05-18 11:27 Re: COALESCE in ORDER BY... Terry Yapt <pgsql@technovell.com>

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