FW: finding firstname + lastname groups

From: Charles Simard <tech(at)denarius(dot)ca>
To: 'blackwater dev' <blackwaterdev(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: FW: finding firstname + lastname groups
Date: 2008-06-19 19:56:31
Message-ID: E6AE5AD88D55B543A0A97FF0B93AA9E9621F2A@TRADE200.DENARIUS.CA
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-> -----Original Message-----
-> From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of blackwater dev
-> Sent: 19 juin 2008 15:38
-> To: pgsql-general(at)postgresql(dot)org
-> Subject: [GENERAL] finding firstname + lastname groups
->
-> I have to find the same firstname+ lastname combo in my db and see which
name appears the most so I basically need to do the following:
->
-> select name, count(name) from people group by name having count(name)>1
->
-> The problem is name is not one column but made up of firstname,
lastname...how do I do this?
->
-> Thanks!

Use string concatenation :
http://www.postgresql.org/docs/8.3/interactive/functions-string.html#FUNCTIO
NS-STRING-SQL

select firstname || ' ' || lastname as name, count(firstname || lastname)
from people
having count(firstname || lastname) > 1;

Regards,

Charles Simard

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2008-06-19 20:39:28 Re: finding firstname + lastname groups
Previous Message Philippe Grégoire 2008-06-19 19:51:41 Re: A plpgsql unidentifiable problem.