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
Migration of SQL Server 2008 database to oracle
How do I modify this php script to send a confirmation?
How to avoid zero(s) in front of number(s) disappears in array
Raid 1 Hard drive failed PowerEdge 1850
Embedding iwebbrowser control inside ATL window.
ORA-06502 error when calling stored procedure from Visual Basic 6
cisco 2650 memory expansion options
Exchange server 2007 sp3 in server 2008 R2
How can I convert a custom control that calls User32 and Shell32 to work on Mono?
Printing the details section in group footer