Re: [GENERAL] reverse sorting

From: Mark Jewiss <mark(at)knowledge(dot)com>
To: Marc Tardif <admin(at)wtbwts(dot)com>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] reverse sorting
Date: 2000-01-27 08:47:03
Message-ID: Pine.BSO.4.10.10001270844190.5186-100000@office.knowledge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Holger Klawitter 2000-01-27 09:22:51 finding predecessor
Previous Message Marc 2000-01-27 08:42:28 how to: list of synonyms (Oracle)?