This is my query, I want to get how many numbers of phones call received today as one column, so how do I do a sum using count function?
SELECT (uniquecallerID), [Callername] FROM [dbo].[phonedatabase] (nolock) WHERE calltime BETWEEN '2020-08-23' AND '2020-08-24' -- GROUP BY whatever
If I do a sum, that would just return the total sum? how do I return the total numbers of all calls received today, I would do count uniquecallerID
and then put them into sum. How do I do that?
Sample data:
UniqueID callername ---------------------- 2619 Jack 2358 Travie 2359 Travis S
Advertisement
Answer
Are you looking for count(distinct)
? Assuming that uniqueCallerID
identifies what you want to count:
select count(distinct uniquecallerID) from [dbo].[phonedatabase] (nolock) where calltime >= '2020-08-23' and calltime < '2020-08-24'