SQL Server stored procedure percentage formula

Posted on 2007-07-30
Medium Priority
Last Modified: 2007-07-30
How do I create a percentage as a formula in a stored procedure.  Currently my data is as follows

Field 1 - 960
Field 2 - 636
Field 3 - Field 2 / (Field 1 + Field 2) - answer should be .398 but is coming back with 0

Syntax from the stored procedure Select Statement for the percentage field is

(fEmployeeTracking_Actions.Field1) / (fEmployeeTracking_Actions.Field1 + fEmployeeTracking_Actions.Field2)

Question by:softdimensions
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19593961
cast(fEmployeeTracking_Actions.Field1 as decimal(10,4)) / cast(fEmployeeTracking_Actions.Field1 + fEmployeeTracking_Actions.Field2 as decimal(10,4))

Author Comment

ID: 19593996
Thanks - works perfect

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

850 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