给出格式为
的表格ID Forename Surname 1 John Doe 2 Jane Doe 3 Bob Smith 4 John Doe
你将如何获得输出
Forename Surname Count John Doe 2 Jane Doe 1 Bob Smith 1
对于单个列我只会使用count,但我不确定如何将其应用于多个。
答案 0 :(得分:9)
SELECT Forename, Surname, COUNT(*) FROM YourTable GROUP BY Forename, Surname
答案 1 :(得分:1)
我认为这应该有效:
SELECT Forename, Surname, COUNT(1) AS Num
FROM T
GROUP BY Forename, Surname