Solved

Posted on 2011-10-20

How do I add an if statement to check for sum(n.shippedQtyLy)=0

(sum(n.scanQtyLy)*100)/sum

When I try

if sum(n.shippedQtyLy)=0 then 0 else

(sum(n.scanQtyLy)*100)/sum

I get a syntax error

select n.category,d.item_desc,n.b

sum(n.shippedQtyLy) as shippedQtyLy,sum(n.shipped

sum(n.scanQtyLy) as scanQtyLy,sum(n.scanAmoutL

(sum(n.scanQtyLy)*100)/sum

7 Comments

CASE WHEN sum(n.shippedQtyLy) = 0 then 0 else

(sum(n.scanQtyLy)*100)/sum

Like - Change this

```
(sum(n.scanQtyLy) * 100) / sum(n.shippedQtyLy)
```

to```
CASE sum(n.shippedQtyLy) = 0 THEN 0 ELSE
(sum(n.scanQtyLy) * 100) / sum(n.shippedQtyLy) END
```

, sum(n.shippedQtyLy) as shippedQtyLy

,sum(n.shippedAmoutLy) as shippedAmoutLy

,avg(n.shippedItemPriceLy)

, sum(n.scanQtyLy) as scanQtyLy

,sum(n.scanAmoutLy) as scanAmoutLy

,avg(n.scItemPriceLy) as scItemPriceLy

, case when isnull(sum(n.shippedQtyLy)

, case when isnull(sum(n.shippedAmoutL

(sum(n.scanQtyLy)*100)/isn

how to add IIS SMTP to handle application/Scanner relays into office 365.

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**18** Experts available now in Live!