Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to count if condition is true

Author  Topic 

bulubuk1976
Starting Member

24 Posts

Posted - 2008-09-06 : 22:04:35
I need help. How do I add a resolvecount field that counts the number of 0s and 1s combined from the resolve field? Here is my existing query:

SELECT COALESCE (AVG(overallsat * 1.0), 0) AS overallsa, COALESCE (AVG(resolve * 1.0), 0) AS resolve, COALESCE (AVG(helpfulness * 1.0), 0) AS helpfulness, COALESCE (AVG(amtoftime * 1.0), 0) AS amtoftime, COALESCE (AVG(commskills * 1.0), 0) AS commskills, COUNT(EmpID) AS totalmonitorings FROM DBSalvador.dell_post_call_surveryform WHERE (CallDate >= DATEADD(DAY, DATEDIFF(DAY, '19000107', GETDATE()) / 7 * 7, '19000107') - 29) AND (CallDate <= DATEADD(DAY, DATEDIFF(DAY, '19000107', GETDATE()) / 7 * 7, '19000107') - 23)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-07 : 00:46:17
may be this:-
SELECT COALESCE (AVG(overallsat * 1.0), 0) AS overallsa, COALESCE (AVG(resolve * 1.0), 0) AS resolve, COALESCE (AVG(helpfulness * 1.0), 0) AS helpfulness, COALESCE (AVG(amtoftime * 1.0), 0) AS amtoftime, COALESCE (AVG(commskills * 1.0), 0) AS commskills, COUNT(EmpID) AS totalmonitorings,SUM(CASE WHEN resolve=1 THEN  1 ELSE 0 END) AS resoved,SUM(CASE WHEN resolve=1 THEN  1 ELSE 0 END) AS unresoved
FROM DBSalvador.dell_post_call_surveryform WHERE (CallDate >= DATEADD(DAY, DATEDIFF(DAY, '19000107', GETDATE()) / 7 * 7, '19000107') - 29) AND (CallDate <= DATEADD(DAY, DATEDIFF(DAY, '19000107', GETDATE()) / 7 * 7, '19000107') - 23)
Go to Top of Page
   

- Advertisement -