Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NESTED CASE STATEMENT

Status
Not open for further replies.

lyudmila

Programmer
Oct 18, 2002
54
US
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: &quot; Line 11, Incorrect syntax near the keyword 'else' &quot;.
 
You didn't put and END statement to close out the nested case statement preceding line 11.

Chris.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top