Re: [GENERAL] reverse sorting - Mailing list pgsql-general

From Mark Jewiss
Subject Re: [GENERAL] reverse sorting
Date
Msg-id Pine.BSO.4.10.10001270844190.5186-100000@office.knowledge.com
Whole thread Raw
In response to reverse sorting  (Marc Tardif <admin@wtbwts.com>)
List pgsql-general
Hello,

On Wed, 26 Jan 2000, Marc Tardif wrote:

> I need to sort the domains of email addresses from right to left, so that
> all similar domains are grouped together. For instance, all .ca's will be
> in the same batch.

> select email from table1, table2 where table1.oid=table2.id order by
> table2.reverse_domain;

Hmmmm.....you don't really want to sort by the reverese domain though. If
you did, you'd end up sorting on ac. instead of .ca, so simply reversing
the string would not work.

Splitting the string on the '.' might also prove a problem as you could
have .ca and .co.uk for example.

One solution (that you probably don't want to hear - I know I wouldn't) is
to change the table to store the domain in separate parts - one column for
the user, one for the domain and one for the domain suffix.

Regards,

Mark.
--
Mark Jewiss
Knowledge Matters Limited
http://www.knowledge.com


pgsql-general by date:

Previous
From: Jim Mercer
Date:
Subject: finding last element of an index
Next
From: "Marc"
Date:
Subject: how to: list of synonyms (Oracle)?