Reputation: 3492
How to get Distinct Count of First Name, Last Name based on DOB. Assuming that Two persons can share same name but not DOB.
SELECT COUNT((DISTINCT [First Name], [Last Name], [DOB])) AS TotalCount
FROM MyTable
Upvotes: 0
Views: 3230
Reputation: 1
I think this query could be sufficient to answer this question. It may not be optimal coz I'm just a newbie
select distinct concat([First Name],' ',[Last Name],' ',DOB) from Orders
Upvotes: 0
Reputation: 69554
shouldn't this be as simple as
SELECT [First Name]
,[Last Name]
,[DOB]
,COUNT(*) AS TotalCount
FROM MyTable
GROUP BY [First Name]
,[Last Name]
,[DOB]
Upvotes: 2
Reputation: 6781
You should be able to get this info like this:
SELECT COUNT(1) AS TotalCount
FROM ( SELECT [First Name] ,
[Last Name] ,
[DOB]
FROM MyTable
GROUP BY [First Name] ,
[Last Name] ,
[DOB]
) a
Upvotes: 2