0
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

感谢您的帮助!

4

1 回答 1

0

扩展您的查询

HAVING t1.f1=SUM(t2.f1)
ORDER BY t1.f1
于 2012-06-21T05:36:52.593 回答