SQLTeam.com | Weblogs | Forums

Sum of Column


#1

I have a query and I want to get the overall Sum of the values returned for NumberDuplicates in below query:

SELECT FirstName, LastName, COUNT() AS NumberDuplicates
FROM CitizenContactJ
GROUP BY FirstName, LastName
HAVING (COUNT(
) > 1)
ORDER BY FirstName

anyone know how to do this?


#2

group by rollup(FirstName, LastName)


#3

You can try

SELECT SUM(NumberDuplicates) as NumberDuplicates
FROM
(
SELECT FirstName, LastName, COUNT() AS NumberDuplicates
FROM CitizenContactJ
GROUP BY FirstName, LastName
HAVING (COUNT(
) > 1)
) as t