Search Postgresql Archives

FW: finding firstname + lastname groups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux