Connecting two sql statement

Hi, I have an sql statment that use a case :

SELECT EngSec, SUM(CASE WHEN ActionType = 'close' THEN TotalNoOfCalls ELSE 0 END) AS [Close],
SUM(CASE WHEN ActionType = 'resolved' THEN TotalNoOfCalls ELSE 0 END) AS [Resolved],
SUM(CASE WHEN ActionType = 'pending' THEN TotalNoOfCalls ELSE 0 END)  AS [Pending],
sum(case when ActionType is null then TotalNoOfCalls Else 0 end) as [Assign],
sum(case when ActionType ='cancel' then TotalNoOfCalls Else 0 end) as [Canceled]
FROM CallStatusbySec GROUP BY EngSec

and i have another statment that use a date interval for the same table:

SELECT * from CallStatusbySec WHERE
CAST(CONVERT(varchar, AssignDate, 101)as datetime)  <= '12/7/2007'
AND CAST(CONVERT(varchar, AssignDate, 101)as datetime)  >= '12/1/2007'

which is the second SQL statment must be the first.
Is there any way to link these two sql statment in one SQL statment?
please help me

LVL 1
AZZA-KHAMEESAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ee_rleeCommented:
i'm not really sure what you want in as your output. but if what you want is to get the sums (from the first table) between some dates (from the 2nd table), try this:


SELECT EngSec, SUM(CASE WHEN ActionType = 'close' THEN TotalNoOfCalls ELSE 0 END) AS [Close],
SUM(CASE WHEN ActionType = 'resolved' THEN TotalNoOfCalls ELSE 0 END) AS [Resolved],
SUM(CASE WHEN ActionType = 'pending' THEN TotalNoOfCalls ELSE 0 END)  AS [Pending],
sum(case when ActionType is null then TotalNoOfCalls Else 0 end) as [Assign],
sum(case when ActionType ='cancel' then TotalNoOfCalls Else 0 end) as [Canceled]
FROM CallStatusbySec 
WHERE
CAST(CONVERT(varchar, AssignDate, 101)as datetime)  <= '12/7/2007'
AND CAST(CONVERT(varchar, AssignDate, 101)as datetime)  >= '12/1/2007'
GROUP BY EngSec

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AZZA-KHAMEESAuthor Commented:
this is simple i thought i have to write more complicated sql. :)
Thanks alot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.