Microsoft
Software
Hardware
Network
Question : MS Access SQL Divide by Zero workaround needed
I am writing some SQL (using Access 2007) that sums a column and then uses this value to calculate a percentage of another summed column. However, if there is no data for the denominator summed column, I get the #error result (divide by zero). How can I just replace this quotient with a zero instead of the #error value?
If Sum(Sales.[Total Sales]) below is 0, then I get the #error value for PayrollPercent, and the form that PayrollPercent value is displayed in does not work (not sure why it does not work and simply does not display #error, but that is a separate question)
1:
SELECT Sum(Sales.Payroll)/Sum(Sales.[Total Sales]) AS PayrollPercent FROM Sales
Answer : MS Access SQL Divide by Zero workaround needed
SELECT IIF(Sum(Sales.[Total Sales])=0,0, Sum(Sales.Payroll)/Sum(Sal
es.[Total Sales]) ) AS PayrollPercent FROM Sales
mx
Random Solutions
WebClient Service in Windows 2000
Can't email more than one invoice from Quickbooks Pro 2006 in Outlook
Cannot pull Data from Oracle using SSIS
Windows 7 clients cannot connect to the server
XP 10 inbound connection limit question
Retain selected value from dynamic drop down php
Hyper-V P2V VM Continuous Blue Screen
refresh ribbon any time a worksheet is activated
WSUS report
Click on an item in a list box and have that value populate a text field