Solved

Database Function Formula

Posted on 2007-04-09
1
260 Views
Last Modified: 2010-06-21
Hi There,

I've been staring at this for some time and I can't figure out why I'm getting 0.000 for an answer.

I've tested my other code in my function and they are working great, it's just when I try to calculate my rating, it keeps returning 0.00.

I've gotten 578 for @TotalAttended and 2 for @TotalAcceptedRefunds, using the formula below, I should be getting back: 0.9965

PRINT @TotalAttended
PRINT @TotalAcceptedRefunds

/* Return 0, if there are no participants that have attended the course */
IF @TotalAttended > 0
     SET @Rating =  (@TotalAttended - @TotalAcceptedRefunds)/@TotalAttended
      
PRINT @Rating

Anyone got an idea, what is wrong with my formula?
0
Comment
Question by:quanmac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18878726
please try this:
IF @TotalAttended > 0
     SET @Rating =  cast(@TotalAttended - @TotalAcceptedRefunds as decimal(10,4))/cast(@TotalAttended as decimal(10,4))
     
PRINT @Rating
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question