convert function from Access SQL to T-SQL 2005

Posted by Pace on Stack Overflow See other posts from Stack Overflow or by Pace
Published on 2010-05-05T11:03:05Z Indexed on 2010/05/05 11:08 UTC
Read the original article Hit count: 140

Filed under:
|
|

Can someone please convert this access sql function for me to work in t-sql 2005.

I am tring to take the selling price minus the cost as one number. And divide that by the original selling price to produce a second number

Thanks :)

 =IIf([Selling Price]=0,0,([Selling Price]-Nz([Cost]))/[Selling Price])

IIRC it should be something along the lines of;

ISNULL((ISNULL([Selling Price],0) - ISNULL(Cost,0)),0) / ISNULL([Selling Price],0) AS Margin

But here I am getting a divide by Zero error.

any suggestions?

© Stack Overflow or respective owner

Related posts about ms-access

Related posts about function