Received: from nezu.gs.verio.net (nezu.gs.verio.net [204.27.65.34]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4ALF9A66200 for ; Thu, 10 May 2001 17:15:09 -0400 (EDT) (envelope-from jeckermann@verio.net) Received: by NEZU with Internet Mail Service (5.5.2650.21) id <2XWDMQBP>; Thu, 10 May 2001 16:14:58 -0500 Message-ID: <08CD1781F85AD4118E0800A0C9B8580B094A78@NEZU> From: Jeff Eckermann To: "'herve@elma.fr'" , pgsql-sql@postgresql.org Subject: RE: Order by email address by domain ? Date: Thu, 10 May 2001 16:14:58 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id f4ALF9A66202 X-Archive-Number: 200105/80 X-Sequence-Number: 2881 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