Re: [SQL] Howto to force NULL rows at the bottom ? - Mailing list pgsql-sql

From Stoyan Genov
Subject Re: [SQL] Howto to force NULL rows at the bottom ?
Date
Msg-id 199912060916.LAA27713@lorna.digsys.bg
Whole thread Raw
In response to Re: [SQL] Howto to force NULL rows at the bottom ?  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-sql
Sorry, sorry, sorry :-(((
I HAVE tested it, but with the WRONG test.
Please do not laugh too loud...

lorna:[11:03]:/usr/home/genov/ 
: createdb tmp
lorna:[11:03]:/usr/home/genov/ 
: psql tmp
Welcome to the POSTGRESQL interactive sql monitor: Please read the file COPYRIGHT for copyright terms of POSTGRESQL
  type \? for help on slash commands  type \q to quit  type \g or terminate with semicolon to execute queryYou are
currentlyconnected to the database: tmp
 

tmp=> select version();
version                                                             
--------------------------------------------------------------------
PostgreSQL 6.5.2 on i386-unknown-freebsd3.1, compiled by gcc 2.7.2.1
(1 row)

tmp=> create table a (d datetime default now()+'@60 days', t text);
CREATE
tmp=> insert into a (t) values (NULL);
INSERT 458155 1
tmp=> \g          
INSERT 458156 1
tmp=> \g
INSERT 458157 1
tmp=> insert into a (t) values ('a');
INSERT 458158 1
tmp=> insert into a(t) values ('b');
INSERT 458159 1
tmp=> insert into a(t) values ('c');
INSERT 458160 1
tmp=> select * from a;
d                           |t
----------------------------+-
Fri 04 Feb 11:04:45 2000 EET| 
Fri 04 Feb 11:04:51 2000 EET| 
Fri 04 Feb 11:04:52 2000 EET| 
Fri 04 Feb 11:05:08 2000 EET|a
Fri 04 Feb 11:05:14 2000 EET|b
Fri 04 Feb 11:05:26 2000 EET|c
(6 rows)

tmp=> select * from a order by t;
d                           |t
----------------------------+-
Fri 04 Feb 11:05:08 2000 EET|a
Fri 04 Feb 11:05:14 2000 EET|b
Fri 04 Feb 11:05:26 2000 EET|c
Fri 04 Feb 11:04:45 2000 EET| 
Fri 04 Feb 11:04:51 2000 EET| 
Fri 04 Feb 11:04:52 2000 EET| 
(6 rows)

tmp=> select * from a order by t desc;
d                           |t
----------------------------+-
Fri 04 Feb 11:05:26 2000 EET|c
Fri 04 Feb 11:05:14 2000 EET|b
Fri 04 Feb 11:05:08 2000 EET|a
Fri 04 Feb 11:04:45 2000 EET| 
Fri 04 Feb 11:04:51 2000 EET| 
Fri 04 Feb 11:04:52 2000 EET| 
(6 rows)

tmp=>  

I just DID NOT put the "order by" clause in the first select, so the tuples 
with the NULL
values appeared first. But that isn't ordered selection :-(

I apologize. I am really sorry.

Regards,
Stoyan Genov



pgsql-sql by date:

Previous
From: Dirk Lutzebaeck
Date:
Subject: Re: [SQL] Howto to force NULL rows at the bottom ?
Next
From: Frank Joerdens
Date:
Subject: Re: [SQL] How to avoid "Out of memory" using aggregate functions?