Thanks Adam. No, It doesn't. But I have found a solution which works : select name from (select distinct name from t) as name order by replace(name, '.', 'a'); name ---------- co.aaa co.abb co.cab co.ment com com.enta (6 lines) Thanks to all of you. Adam Rich wrote : >> By the way, I have just inserted a duplicate. Then I have run the >> select statement with distinct and I got an error. >> >> How one can solve this? >> > > Does this work? > > select distinct name > from ( select name from t order by replace(name, '.', 'a')) as t2 > > > -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general