Re: [SQL] Howto to force NULL rows at the bottom ?

From: Stoyan Genov <genov(at)digsys(dot)bg>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, Inoue(at)tpf(dot)co(dot)jp, pgman(at)candle(dot)pha(dot)pa(dot)us, lutzeb(at)aeccom(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Howto to force NULL rows at the bottom ?
Date: 1999-12-06 09:16:43
Message-ID: 199912060916.LAA27713@lorna.digsys.bg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 query
You are currently connected 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

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Joerdens 1999-12-06 12:56:53 Re: [SQL] How to avoid "Out of memory" using aggregate functions?
Previous Message Dirk Lutzebaeck 1999-12-06 08:37:18 Re: [SQL] Howto to force NULL rows at the bottom ?