Link to home
Start Free TrialLog in
Avatar of jnj_web_solutions
jnj_web_solutionsFlag for India

asked on

How to add values in tree nodes

I want to add LPV,RPV,LAmount,RAmount.

select sum(LPV) as Lv, sum(RPV) as Rv, sum(LAmount + RAmount) as Total from ( select leftn as SId, LPV, RPV, LAmount, RAmount from amount inner join (select @sid:=(select group_concat(leftn,',',rightn) from amount where find_in_set(sid, @nsid) >= 1), @nsid:=@sid as fset from amount, (select @nsid:='AMSJOXOLO',@sid='')v )gr on find_in_set(leftn,fset) where leftn <> '' union select rightn as SId, LPV, RPV, LAmount, RAmount from amount inner join (select @sid:=(select group_concat(leftn,',',rightn) from amount where find_in_set(sid, @nsid) >= 1), @nsid:=@sid as fset from amount, (select @nsid:='AMSJOXOLO',@sid='')v )gr on find_in_set(rightn,fset) where rightn <> '')x

When i am execute this above code, I got output like below:
User generated image

But this addition program shows wrong output.

The original output is:

Lv         Rv        Total
19.5      21.5    2050

I need the addition query to show the original values like above output.
amount.sql
ASKER CERTIFIED SOLUTION
Avatar of Lee Wadwell
Lee Wadwell
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial