• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

sql case when as statement

can someone help me with this sql statment. it will not work, it keep saying invalid new then.  

select
case when ((slsrepplan.planamt = 0 then 0) else slsrepplan.actamt/slsrepplan.planamt) as "plan%"

from slsrepplan
0
kelsanit
Asked:
kelsanit
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:

select
case when slsrepplan.planamt = 0 then 0 else slsrepplan.actamt/slsrepplan.planamt END as "plan%"

from slsrepplan
0
 
lofCommented:
Try this
select
case when slsrepplan.planamt = 0 then 0 else slsrepplan.actamt/slsrepplan.planamt end as "plan%"
from slsrepplan

Open in new window

0
 
tigin44Commented:
select      case when slsrepplan.planamt = 0 then 0
                   else slsrepplan.actamt/slsrepplan.planamt)
            end as "plan%"
from slsrepplan
0
 
shru_0409Commented:
if slsrepplan.planamt column default zero the this above case statement is prefectly rigth. if not than u have to write link this

select case when nvl(slsrepplan.planamt,0) = 0 then 0 else slsrepplan.actamt/slsrepplan.planamt End as "plan%"
decode

u can write also like this

select decode (slsrepplan.planamt,0,0,slsrepplan.actamt/slsrepplan.planamt) as "plan%" from slsrepplan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now