From: Jeff Eckermann <jeckermann@verio.net>
To: 'herve@elma.fr' <herve@elma.fr>
To: pgsql-sql@postgresql.org
Subject: RE: Order by email address by domain ?
Date: Thu, 10 May 2001 16:14:58 -0500
Message-ID: <08CD1781F85AD4118E0800A0C9B8580B094A78@NEZU> (raw)
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@elma.fr]
> Sent: Thursday, May 10, 2001 1:38 PM
> To: pgsql-sql@postgresql.org
> Subject: Order by email address by domain ?
>
> Hi,
>
> I just want to order by a listing of email address by domain like :
>
> toto@aol.com
> tutu@aol.com
> toto@be.com
> tutu@be.com
> toto@yahoo.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@elma.fr
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jeckermann@verio.net, herve@elma.fr
Subject: Re: Order by email address by domain ?
In-Reply-To: <08CD1781F85AD4118E0800A0C9B8580B094A78@NEZU>
References: <08CD1781F85AD4118E0800A0C9B8580B094A78@NEZU>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox