January 9, 2020 at 10:32 pm
Hi all
I need help with writing a SQLstatement for an Arithmetic expression (Division) by joining two tables.
How can I get % Score as a Calculated Field?
Say for example 1st row in the screenshot is 15/183 = 0.0819. I need to see (100-(15/183*100)) = 91.80 which would the the Percentage of the two fields for a person.
SELECT *
FROM [dbo].[Calls_OutsideSLA] OS
INNER JOIN [dbo].[Calls_InsideSLA] INS ON ( OS.Person= INS.Person)
January 10, 2020 at 2:41 pm
It's really quite straightforward
Where X and Y are the two values from your results (OS.RecordCount and INS.RecordCount respectively ) use the following formula (a simplified version of your own):
(y-x/y)*100
In your SELECT statement eg.
SELECT 100.0 * (Y-X)/Y
FROM ...<your results>...
As it looks like your RecordCounts are integers you must ensure you cast your values to a decimal value (with appropriate precision and scale) or you will see just zeroes (probably) in your results. See CAST and DECIMAL in the docs
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy