Thursday, March 22, 2012

CASE PROBLEM

I am using the following snippet of code:

ACCOUNT =
case left(m.gldebitacct, 6)
when '700048' then '40700-497-00'
when '011195' then '60700-470-05'
else 'error'
end,

I need to alter this code to deal with another case such as:

case left(m.glcreditacct, 6)
when '700048' then '40700-497-00'
when '011195' then '60700-470-05'
else 'error'
end,

I think it should look like the following, but when I try this I get an error:

ACCOUNT =
case left(m.gldebitacct, 6)
when '700048' then '40700-497-00'
when '011195' then '60700-470-05'
else 'error'
end,

case left(m.glcreditacct, 6)
when '700048' then '40700-497-00'
when '011195' then '60700-470-05'
else 'error'
end,

Can anyone help with this?ACCOUNT =
case
when left(m.gldebitacct, 6) = '700048' or left(m.glcreditacct, 6) = '700048' then '40700-497-00'
when left(m.gldebitacct, 6) = '011195' or left(m.glcreditacct, 6) = '011195' then '60700-470-05'
else 'error'
end|||That did the trick.

Thanks

No comments:

Post a Comment