RE: Order by email address by domain ?

From: Jeff Eckermann <jeckermann(at)verio(dot)net>
To: "'herve(at)elma(dot)fr'" <herve(at)elma(dot)fr>, pgsql-sql(at)postgresql(dot)org
Subject: RE: Order by email address by domain ?
Date: 2001-05-10 21:14:58
Message-ID: 08CD1781F85AD4118E0800A0C9B8580B094A78@NEZU
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I assume that you want to do this within the database, i.e. with a query.
You would need to use a function, but I don't think a builtin function would
do it.
Try:
CREATE FUNCTION email_order (text) RETURNS text AS '
select substr ($1, strpos ($1, ''@'') + 1) || substr ($1, 1, strpos ($1,
''@'') -1)
' LANGUAGE 'sql';
Then do:
SELECT ..... FROM ... ORDER BY email_order (fieldname);
I am assuming text datatype; substitute as appropriate.
That's doubled single quotes around the @ symbol, by the way.

> -----Original Message-----
> From: Hervé Piedvache [SMTP:herve(at)elma(dot)fr]
> Sent: Thursday, May 10, 2001 1:38 PM
> To: pgsql-sql(at)postgresql(dot)org
> Subject: Order by email address by domain ?
>
> Hi,
>
> I just want to order by a listing of email address by domain like :
>
> toto(at)aol(dot)com
> tutu(at)aol(dot)com
> toto(at)be(dot)com
> tutu(at)be(dot)com
> toto(at)yahoo(dot)com
>
> Is it possible and how ?
>
> Thanks !
> --
> Hervé Piedvache
>
> Elma Ingenierie Informatique
> 6, rue du Faubourg Saint-Honoré
> F-75008 - Paris - France
> http://www.elma.fr
> Tel: +33-1-44949901
> Fax: +33-1-44949902
> Email: herve(at)elma(dot)fr
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl

Browse pgsql-sql by date

  From Date Subject
Next Message Keith Gray 2001-05-11 01:11:46 Escape Quotes
Previous Message Josh Berkus 2001-05-10 20:38:21 Re: Order by email address