Обсуждение: reverse sorting

Поиск
Список
Период
Сортировка

reverse sorting

От
Marc Tardif
Дата:
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.

I think I should be writing a trigger for this, using a secondary table
for the reverse domain name, then using a query like:
select email from table1, table2 where table1.oid=table2.id order by
table2.reverse_domain;

I'm not sure if keeping a secondary table is worthwhile, I will only be
executing this query about 50 times per day.

Let me know if there's a better way,
Marc Tardif


Re: [GENERAL] reverse sorting

От
Mark Jewiss
Дата:
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