-> -----Original Message-----
-> From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of blackwater dev
-> Sent: 19 juin 2008 15:38
-> To: pgsql-general@postgresql.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


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to