Re: SQL - Calculate 100%

  • From: Vladimir Andreev <vandreev@xxxxxxxxx>
  • To: Eriovaldo Andrietta <ecandrietta@xxxxxxxxx>
  • Date: Thu, 25 Nov 2010 12:47:20 +0100

It depends.
May I see the SQL? How do you perform the sum? How do you round/truncate the
individual percentages?

round(100*sum(value2)/value1,2) would definitely return 100.00 with the
example data.
sum(round(100*value2/value1,2)) will be more likely to return 100.00 than
what you are using (and you seem to be using trunc()), but might return
100.01.
group by rollup would return 100.00.

Cheers,
Flado

On Thu, Nov 25, 2010 at 12:29, Eriovaldo Andrietta <ecandrietta@xxxxxxxxx>wrote:

> Vladimir,
>
>   I think that it will not solve the issue.
>   The value can be rounded, but there are several values, and the sum can
> be different of 100%.
>
>

Other related posts: