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 2005 Forums
 Transact-SQL (2005)
 Silly question...case..within a case?

Author  Topic 

dlorenc
Posting Yak Master

172 Posts

Posted - 2009-02-10 : 11:49:43
can I have a case...within a case??? (ms sql 2005)

select SUM(CASE when Actual_End_Date is null then 0 else SUM(CASE when Requested_Completion_Date_ >= Actual_End_Date then 1 else 0 end))AS MetricValue FROM CHG_Change

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-02-10 : 12:05:42
sure
select
case
when 1=1 then case when 2=2 then 'yes' else 'no'end
else 'that is all'
end


Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

dlorenc
Posting Yak Master

172 Posts

Posted - 2009-02-10 : 12:24:50
Thank you!... I looked closer and realized I should have filtered the initial select with a where...this eliminated the need for nested case's...

select
SUM(CASE when Requested_Completion_Date_ >= Actual_End_Date then 1 else 0 end)
AS MetricValue
FROM CHG_Change where Actual_End_Date is not null
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-02-10 : 12:31:22
That's fine!
I have not had a look at it.
Only spend time on posting about nested case...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -