giles
giles

Reputation: 843

trouble with WHEN NOT NULL

I want to create a switch around the following. I've tried various permutations but I just cant get IS NOT NULL to work.

(CASE billing_code WHEN NOT NULL  THEN billing_amount END) AS Billing Amount

Thanks in advance

Upvotes: 1

Views: 288

Answers (2)

Try as below

  (Case When billing_code is Not Null then billing_amount End) As "Billing Amount"

Upvotes: 1

Martin Smith
Martin Smith

Reputation: 452988

You need to use the "searched" form of the CASE statement. Additionally as the column alias contains spaces it needs to be delimited as below.

CASE  WHEN billing_code IS NOT NULL  THEN billing_amount END AS [Billing Amount]

Upvotes: 1

Related Questions