Обсуждение: FW: finding firstname + lastname groups

Поиск
Список
Период
Сортировка

FW: finding firstname + lastname groups

От
Charles Simard
Дата:
-> -----Original Message-----
-> From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On 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