tags:

views:

39

answers:

2

Given a table in the format of

ID   Forename    Surname
1    John        Doe
2    Jane        Doe
3    Bob         Smith
4    John        Doe

How would you go about getting the output

Forename  Surname  Count
John      Doe      2
Jane      Doe      1
Bob       Smith    1

For a single column I would just use count, but am unsure how to apply that for multiple ones.

+6  A: 
SELECT Forename, Surname, COUNT(*) FROM YourTable GROUP BY Forename, Surname
Larry Lustig
+1: Beat me by 28 seconds
OMG Ponies
Ah excellent, knew there was a simple way I was missing. Much appreciated.
John
+1  A: 

I think this should work:

SELECT Forename, Surname, COUNT(1) AS Num 
FROM T
GROUP BY Forename, Surname
Michael Goldshteyn