SELECT
t1.f1 AS val1,
SUM(t2.f1) AS val2
FROM t2
INNER JOIN t1 ON t2.f2 = t1.f2
GROUP BY t1.f2
结果如何:
va1 val2
25 8
10 10
25 25
10 1
并希望有一种方法可以使用MySQL查询从两个字段中对相同的值进行排序,数据采用以下格式:
va1 val2
10 10
25 25
感谢你的帮助!
答案 0 :(得分:0)
通过
扩展您的查询HAVING t1.f1=SUM(t2.f1)
ORDER BY t1.f1