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
How to submit an asynchronous request to server to run a business service from a Business component script?
Backup Exec 2010 can not view DAG, Exchange 2010
SCCM 2007 collection by OU not showing all pc's
Generate the members from AD user group
C++ dll in VB
ODBC connect to ORACLE 11G using Redhat Linux 5.4
Fast download/upload, slow surfing
do you need sysprep with Symantec Ghost Solution Suite 2.5?
Use different HTTP Redirects on multiple virtual directories in IIS 7.5
Imail Mail Server blocked. Cant see why