Barry62
asked on
Trouble with SQL Case statement
I am trying to write a query in Argos that uses nested case statements, but I keep getting a syntax error. Can anyone point it out to me?
case lsenrmngt_rec.plan_enr_sess
when 'FA' then
case lsenrmngt_rec.enrstat
when 'READMIT' then
case
when lsenrmngt_rec.deg matches 'A*' then
case lsenrmngt_rec.plan_grad_yr
when year(current) or year(current+1) then
readm2a+1
end
end
end readm2a
ASKER
Could you give me an example?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, I just realized that I don't need a nested statement because I don't want any 'else' conditions. I fixed it like this:
case
when lsenrmngt_rec.plan_enr_sess = 'FA' and lsenrmngt_rec.enrstat = 'READMIT' and lsenrmngt_rec.deg matches 'A*' and lsenrmngt_rec.plan_grad_yr between year(GETDATE()) and year(GETDATE())+1
then +1
else 0
end readm2a
ASKER
I'll give you the points since you got me thinking a different way.
SELECT case lsenrmngt_rec.plan_enr_ses
when 'FA' then
case lsenrmngt_rec.enrstat
when 'READMIT' then
case when lsenrmngt_rec.deg like '%A*%' then
case when lsenrmngt_rec.plan_grad_yr
end
end
End
readm2a
note, you are missing the else part for all the case statement