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
 General SQL Server Forums
 Database Design and Application Architecture
 Subquery help Please

Author  Topic 

bulubuk1976
Starting Member

24 Posts

Posted - 2008-01-18 : 06:09:13
I am trying to get the % of resolved for every calltype based on an input dates. Here is my table:

Table: Win4
SessionDate Calltype Status
---------------------------------------
1/2/2008 Email Resolved
1/3/2008 Email Unresolved
1/4/2008 Connectivity Resolved
1/5/2008 Connectivity Unresolved
1/6/2008 Connectivity Resolved
1/7/2008 General Resolved
1/8/2008 General Resolved
1/9/2008 General Unresolved


Here's my desired result given the parameter dates 1/2/08 to 1/9/2008:

Calltype #Count #Resolved
---------------------------------------
Email 2 1
Connectivity 3 2
General 3 1


Here's my code:

SELECT Calltype, count(Calltype) as #Count
FROM dbo.WIN4
Where Sessiondate >= '1/2/2008' and Sessiondate <= '1/9/2008'
Group by Calltype


Then problem is that I do not know how to count all the RESOLVED with alias #Resolved.

I appreciate any help or who could write the code for me.

Thanks!
Dennis S.



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-18 : 07:08:26
Cross post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95752



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

mdgryn
Starting Member

6 Posts

Posted - 2008-01-21 : 01:18:50
I think this will help you in case it is the desired result

SELECT Calltype, count(Calltype) as #Count
,case when Resolved=1 then 'Resolved' else 'Unresolved' end
FROM dbo.WIN4
Where Sessiondate >= '1/2/2008' and Sessiondate <= '1/9/2008'
Group by Calltype,Sessiondate,case when Resolved=1 then 'Resolved' else 'Unresolved' end

Go to Top of Page
   

- Advertisement -