Grouping summation of mysql concatenated tables

1. Find the score of the grouping in table an and sort it

2.
a Table
id
openid
groups grouping

b Table
id
openid
step score

openid is the associated field of two tables

3. Get the sum of groups grouping corresponding to step scores in table b sorted by groups

Mar.02,2021

solved


SELECT a.groups answer sum (b.step) FROM an INNER JOIN b USING (openid) GROUP BY a.groups ORDER BY a.groups DESC


SELECT a.groups answer sum (b.step) as score FROM a LEFT JOIN b ON a.groups=b.groups GROUP BY a.groups

)
Menu