When running this query I get the Division by Zero error come up, I know that is correct, however I would like it to error to zero if possible.
I have attempted using CASE, and it doesn't seem to allow it to be used in the WHERE clause. This is why I have moved the math to the WHERE part of the query in order to limit the results.
WHERE 100*[StockQTY1]/[ShelfCapacity1]<'$ShowPercent'
Full query:
SELECT [Season],[PLU],[ProductDescription],[SupplierCode],[StockQTY1],[StockQTY3],[ShelfCapacity1],[StockQTY2],[StockRoomLocation],[StockRoomLocation2],[SalePrice1],[StockTakeCount1],[TempStockRoomLocation3],[StockTakeCount2],[StockTakeCount3],[TempStockRoomLocation2]
FROM [PLU]
LEFT JOIN [Stock] ON PLU.PLU = Stock.StockID
WHERE 100*[StockQTY1]/[ShelfCapacity1]<'$ShowPercent'
AND StoreID='$storeID' AND ([StockQTY2]>0 OR [StockTakeCount2]>0) AND (([StockQTY1]<[ShelfCapacity1] OR [StockQTY1]='0') OR ([StockTakeCount1]<[ShelfCapacity1] OR [StockTakeCount1]='0')) AND [DeptID] LIKE '$ShowDepartment'$SeasonShow$NotLikes
ORDER BY [TempStockRoomLocation2] ASC, [StockRoomLocation] ASC, [SupplierCode] ASC
Any help would be very much appreciated.
Thanks