Solved

Database Function Formula

Posted on 2007-04-09
1
255 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
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

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

679 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