?
Solved

Database Function Formula

Posted on 2007-04-09
1
Medium Priority
?
265 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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

777 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