Vignesh Kumar

Vignesh Kumar

  • NA
  • 1k
  • 403.7k

Divide two columns with null values

Aug 14 2014 3:36 AM

Hi,

I am trying to divide these two columns and need
suggestions.

parsename('$'+ Convert(varchar,Convert(money,Q.[Product Cost]-R.[Shared Cost]),1),2) as [Pre Cost],
parsename('$'+ Convert(varchar,Convert(money,R.[New Product Cost]-R.[Shared Cost]),1),2) as [Post Cost]

Formula:

[Post Cost] / [Pre Cost]

Expected:

If [Post Cost] is null then I would need to  assign 1 and divide by [Pre Cost] and similarly if [Pre Cost] is null then I  would need to assign 1 so that I can divide [Post Cost] / [Pre Cost]

Really appreciate any help on this.


Answers (1)