Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B65A09F9E76 for ; Wed, 12 Sep 2007 01:04:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 17299-06 for ; Wed, 12 Sep 2007 01:04:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from rrmailscan3.safenetbox.biz (mailscan3.reynolds.com.au [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id 57D9A9F9FDC for ; Wed, 12 Sep 2007 01:04:09 -0300 (ADT) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 342851D48461 for ; Wed, 12 Sep 2007 14:04:08 +1000 (EST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 6A40C1D48422 for ; Wed, 12 Sep 2007 14:04:07 +1000 (EST) Message-ID: <46E764FB.2070602@autoledgers.com.au> Date: Wed, 12 Sep 2007 12:03:07 +0800 From: Paul Lambert User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Extracting hostname from URI column References: <750084.67431.qm@web50306.mail.re2.yahoo.com> <46E762B4.7080102@autoledgers.com.au> In-Reply-To: <46E762B4.7080102@autoledgers.com.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/98 X-Sequence-Number: 29311 Paul Lambert wrote: > > Just use distinct... > > test=# select distinct count(*),substring( href from '.*://([^/]*)' ) as > domain from url group by domain order by domain; OK so distinct was redundant there... it gives the same results without it. AutoDRS=# select count(*) as occurances,substring( href from '.*://([^/]*)' ) as domain from url group by domain order by occurances desc,domain; occurances | domain ------------+-------------------------- 11 | www.google.com 4 | dictionary.reference.com 4 | texturizer.net 3 | devedge.netscape.com 3 | groups.google.com 2 | forums.mozillazine.org 2 | www.mozillazine.org (7 rows) -- Paul Lambert Database Administrator AutoLedgers