distinct + order by - Mailing list pgsql-hackers

From t-ishii@sra.co.jp (Tatsuo Ishii)
Subject distinct + order by
Date
Msg-id 199811072353.IAA29308@meshsv26.tk.mesh.ad.jp
Whole thread Raw
Responses Re: [HACKERS] distinct + order by  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
6.4 allows to use ORDER BY with a column that does not appear 
in a target list. This is great. However, following result seems
strange to me. Sometimes DISTINCT does not remove duplication.
Is this normal behavior?

create table dtest (i text, j date, k int);
CREATE
insert into dtest values ('a', '1998/12/1', 1);
INSERT 215243 1
insert into dtest values ('a', '1998/12/2', 2);
INSERT 215244 1
insert into dtest values ('a', '1998/12/3', 3);
INSERT 215245 1
select * from dtest;
i|         j|k
-+----------+-
a|12-01-1998|1
a|12-02-1998|2
a|12-03-1998|3
(3 rows)

select distinct i from dtest;
i
-
a
(1 row)

select distinct i from dtest order by j;
i
-
a
a
a
(3 rows)

select distinct i from dtest order by k;
i
-
a
a
a
(3 rows)

--
Tatsuo Ishii
t-ishii@sra.co.jp



pgsql-hackers by date:

Previous
From: Constantin Teodorescu
Date:
Subject: Bugs on opening views defined with spaces or upon table names with spaces !!!
Next
From: Terry Mackintosh
Date:
Subject: regression tests