• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 852
  • Last Modified:

SQL Server stored procedure percentage formula

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)

0
softdimensions
Asked:
softdimensions
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
cast(fEmployeeTracking_Actions.Field1 as decimal(10,4)) / cast(fEmployeeTracking_Actions.Field1 + fEmployeeTracking_Actions.Field2 as decimal(10,4))
0
 
softdimensionsAuthor Commented:
Thanks - works perfect
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now