Link to home
Start Free TrialLog in
Avatar of leezac
leezac

asked on

Case Statement where one column is null

I have two columns LOAN_CT and LOAN_BAL.
In the below statement I am needing to show '0' in LOAN_NO column row  if LOAN_BAL is null else count LOAN_CT.


 SUM( case when (Loan_Bal) > 0 then count(LOAN_CT) else 0 end) as "Count of Loans",
Avatar of Sean Stuber
Sean Stuber

please post sample data and expected output
I don't understand this - >  LOAN_NO column row

what is LOAN_NO? how does it relate to the rest of the sql

what do you mean by "column row" ?

sample data and expected output should help immensely
To get a 0 when there is a null use: NVL(some_column,0)

I'm not understanding what you really want here.
ASKER CERTIFIED SOLUTION
Avatar of leezac
leezac

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
case when loan_bal = 0 then 1 else loan_ct end loan_ct
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leezac

ASKER

I agree with all of the solutions presented - thank you.