DIVIDATE total values of 2 tables in MySql

0

In a previous post and with the idea of this forum, I managed to add the values of 2 tables that are identical in the structure.

  

select sum (AP) AP, sum (T) T, sum (CA) CA, sum (H) H, sum (2H) 2H, sum (3H)   3H, sum (HR) HR, sum (CE) CE, sum (BB) BB, sum (P) P, sum (BR) BR, sum (SF)   SF, sum (TB) TB from (       select AP, T, CA, H, 2H, 3H, HR, CE, BB, P, BR, SF, TB from stats where id = 10 union all       select AP, T, CA, H, 2H, 3H, HR, CE, BB, P, BR, SF, TB from stats2017 where id = 6) x

and he correctly showed me the sum of the 2 tables.

Now what I'm missing is calculating the average is by dividing the total value between H / T , but it must be from the sum of the 2 tables.

    
asked by Granedoy 06.01.2018 в 20:55
source

1 answer

1

PROBLEM SOLVED

I had this query that I only added the data of my 2 tables select sum(AP) AP, sum(T) T, sum(CA) CA, sum(H) H, sum(2H) 2H, sum(3H) 3H, sum(HR) HR, sum(CE) CE, sum(BB) BB, sum(P) P, sum(BR) BR, sum(SF) SF, sum(TB) TB from ( select AP, T, CA, H, 2H, 3H, HR, CE, BB, P, BR, SF, TB from stats where id=10 union all select AP, T, CA, H, 2H, 3H, HR, CE, BB, P, BR, SF, TB from stats2017 where id=6 ) x What I did was then add FORMAT(sum(H)/sum(T),3) Promedio just before the from

    
answered by 06.01.2018 / 22:20
source