473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Avoid division by 0 errors

1
Hi when i run the following view i get division by 0 errors for the new data this month. can someone show me how to alter it so that only certain parts of the query result in a 0 number and not the entire statement. thanks.

CREATE VIEW dbo.viewTopOfHierarchy
AS
SELECT TOP 100 PERCENT Yr, Period, COUNT(Employee) AS [Number Of Technicians], ID AS [Month], SUM([Reg Hrs]) AS [Reg Hrs], SUM([OT Hrs]) AS [OT Hrs],
SUM([Stand Down]) AS [Stand Down], SUM([On Call]) AS [On Call], SUM([Personal Milage]) AS [Personal Mileage], SUM([Total Expenses])
AS [Total Expenses], SUM([Total Hours Distributed]) AS [Total Hours Distributed], SUM([Total Volume SA]) AS [Total Volume SA], SUM([Total Volume SF])
AS [Total Volume SF], SUM([Total Duration SA]) AS [Total Duration SA], SUM([Total Duration SF]) AS [Total Duration SF],
FLOOR(100 * ((SUM([Total Duration SF]) + SUM([Total Duration SA])) / (SUM([Total Volume SA]) + SUM([Total Volume SF])))) / 100 AS [Avg Duration],
SUM([Total Hours Invoiced]) AS [Total Hours Invoiced], SUM([Total Hours Undistributed]) AS [Total Hours Undistributed], FLOOR(100 * (SUM([OT Hrs])
* 100 / SUM([Reg Hrs]))) / 100 AS [%OT], FLOOR(100 * (SUM([Total Hours Distributed]) / SUM([Total Hours Invoiced]) * 100))
/ 100 AS [ % Hours Distrubuted in Awas], FLOOR(100 * (SUM([Total Hours Distributed]) / COUNT(Employee)))
/ 100 AS [Average Work Hours Per Technician], SUM([Reg Hrs]) + SUM([OT Hrs]) + SUM([Stand Down]) + SUM([Stand Down]) + SUM([On Call])
+ SUM([Personal Milage]) + SUM([Total Expenses]) + SUM([Total Hours Distributed]) + SUM([Total Volume SA]) + SUM([Total Volume SF])
+ SUM(AvgDuration) + SUM([Total Hours Invoiced]) + SUM([Total Hours Undistributed]) + SUM([%OT]) AS YTD
FROM dbo.viewScorecard
GROUP BY Yr, Period, ID
ORDER BY ID



sorry its very complicaed and didnt post well.
Jul 25 '06 #1
1 1662
ronverdonk
4,258 Expert 4TB
I guess you have to enclose your divisors in IFNULL() statements. See http://dev.mysql.com/doc/refman/4.1/en/control-flow-functions.html

Ronald :cool:
Aug 1 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Brad Tilley | last post by:
Hello, What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I...
17
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab...
9
by: PengYu.UT | last post by:
Hi, The usually integer division will round the result to the biggest integet smaller than the float version division.For example, 10/3 = 3. I'm wondering if there is any easy way to round it...
2
by: kermit | last post by:
For a long time,, There has been a discussion of trueFor division versus integer division in Python. I myslef prefer that / be used for integer division since almost always, I want the...
13
by: jamesonang | last post by:
Supposed unsigned int(32 bits) is the largest number that computer can represent with a single variable. Now, i have a big integer ( less than 64 bit, but great than 32 bit) . i represent it by...
31
by: krypto.wizard | last post by:
How to divide a number by 7 efficiently without using - or / operator. We can use the bit operators. I was thinking about bit shift operator but I don't know the correct answer.
94
by: krypto.wizard | last post by:
Last month I appeared for an interview with EA sports and they asked me this question. How would you divide a number by 7 without using division operator ? I did by doing a subtraction and...
1
by: youjay | last post by:
I've been out of perl for a while, so I am starting from scratch. I have a small applet which scans a set of directories, getting information from some files in each one, and displaying selected...
4
by: Astley Le Jasper | last post by:
I've been getting errors recently when using pysqlite. I've declared the table columns as real numbers to 2 decimal places (I'm dealing with money), but when doing division on two numbers that...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.