Reputation: 6778
I have following table
How can I get ratio values ?
The ratio between the values in the "Value" column, the sum is always 1 as 100%.
the number of rows in the table is not limited, there can be more Number1, Number2, Code combinations.
SQL Fiddle http://sqlfiddle.com/#!3/95fc1
Upvotes: 0
Views: 6032
Reputation: 72165
Try this:
SELECT Number1, Number2,
[Ratio] / (SUM([Ratio]) OVER (PARTITION BY Number1, Number2) * 1.0)
FROM Example
Upvotes: 1