jnj_web_solutions
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,',',rig htn) 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,',',rig htn) 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:
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
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,',',rig
When i am execute this above code, I got output like below:
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.