I have a column that calculates Unit Weight (g) by doing the following calculations
SELECT ROUND (Weight,0) / nullif ([Units per Carton],0) * 454 AS [Unit Weight (g)]
FROM [Item Master]
I used the nullif to eliminate the divide by zero. but i also want to use the Round() on the divisor
i tried this:
SELECT ROUND (Weight,0) / nullif(Round([Units per Carton],0) * 454) AS [Unit Weight (g)]
FROM [Item Master]
i tried this:
SELECT nullif (ROUND (Weight,0) / (Round([Units per Carton],0) * 454) AS [Unit Weight (g)]
FROM [Item Master]
error: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'AS'.
**So how do i combine a round function with nullif on the divisor?? **
Newly Edited Code
SELECT ROUND (Weight,0) / nullif([Units per Carton],0) * 454 AS [Unit Weight (g)]
FROM [Item Master]
SELECT ROUND (Weight / NULLIF([Units per Carton],0),0) * 454 AS [Unit Weight (g)]
FROM [Item Master]
I tried the above and the result i got is in this -> picture
The results are different i wanted the result to be 151, 227 and 227 but those results are getting replaced by 0's.