如何获得基于DOB的名字,姓氏的不同计数。假设有两个人 可以共享相同的名称,但不能共享。
SELECT COUNT((DISTINCT [First Name], [Last Name], [DOB])) AS TotalCount
FROM MyTable
答案 0 :(得分:2)
你应该能够得到这样的信息:
SELECT COUNT(1) AS TotalCount
FROM ( SELECT [First Name] ,
[Last Name] ,
[DOB]
FROM MyTable
GROUP BY [First Name] ,
[Last Name] ,
[DOB]
) a
答案 1 :(得分:2)
不应该像
一样简单SELECT [First Name]
,[Last Name]
,[DOB]
,COUNT(*) AS TotalCount
FROM MyTable
GROUP BY [First Name]
,[Last Name]
,[DOB]