Nested IIf to CASE STATEMENT

Mittle

Member
Local time
Today, 06:39
Joined
Dec 2, 2020
Messages
105
hello

Can someone please help to translate this IIF statement to CASE WHEN. tried doing this myself but not working


--IIf(Sum(IIf([QTR_ID]=[QtrID],1,0))>0,"Yes","No") AS [Change This Qtr Y/N]


CASE

(
SUM(CASE
WHEN [QTR_ID]=[QtrID] THEN 1 ELSE 0)) WHEN >0 THEN YES ELSE NO

END
)
END

AS [Change This Qtr Y/N]
 
can I not use CASE as its much easier . I just need the the code to be translated thats all
 
case when (sum(case when [QTR_ID]=[QtrID] then 1 else 0 end)) > 0 then 'Yes' else 'No' end as [Change This Qtr Y/N]
 
case when (sum(case when [QTR_ID]=[QtrID] then 1 else 0 end)) > 0 then 'Yes' else 'No' end as [Change This Qtr Y/N]
Fantastic. thanks ever so much for the prompt response .Works perfect
 
i forgot to tell you that the Query is an Aggregate (total query) so
you need to have a Group By clause on it.
 
oh Yes thanks ,

I only copied the part of the query as I get confused with the nested IIFs and where to put the brackets etc

. yes the FROM clause has the GROUP BY.
 

Users who are viewing this thread

Back
Top Bottom