What is wrong with this syntax?
select
vnd_nbr = ltrim(f1),
vnd_name = ltrim(f2),
invnbr = ltrim(f3),
invdt = f4,
case when ltrim(rtrim(f5))='1' then
case when ltrim(rtrim(f6))='X' then
cast(f7*-1 as numeric(15,2))
else
cast('0' as numeric(15,2))
else
case when ltrim(rtrim(f8))<>'M' and ltrim(rtrim(f9))<>'30' then
cast(f7 as numeric(15,2))
else
cast('0' as numeric(15,2))
end as invamt
from MyTable
Error says: " Line 11, Incorrect syntax near the keyword 'else' ".
select
vnd_nbr = ltrim(f1),
vnd_name = ltrim(f2),
invnbr = ltrim(f3),
invdt = f4,
case when ltrim(rtrim(f5))='1' then
case when ltrim(rtrim(f6))='X' then
cast(f7*-1 as numeric(15,2))
else
cast('0' as numeric(15,2))
else
case when ltrim(rtrim(f8))<>'M' and ltrim(rtrim(f9))<>'30' then
cast(f7 as numeric(15,2))
else
cast('0' as numeric(15,2))
end as invamt
from MyTable
Error says: " Line 11, Incorrect syntax near the keyword 'else' ".