1
SELECT x,y,SUM(f)-SUM(g) 
FROM a,b 
WHERE a.x = b.x 
GROUP BY SUM(f)-SUM(g)
HAVING SUM(f)-SUM(g)>1

尝试使用 GROUP BY x 时,它可以工作,但我怎样才能 GROUP BY SUM(f)-SUM(g) ?

4

1 回答 1

4

您不需要按聚合列分组。你需要的是

SELECT x,y,SUM(f)-SUM(g)  
FROM a,b  
WHERE a.x = b.x  
GROUP BY x,y 
HAVING SUM(f)-SUM(g)>1 
于 2012-07-16T12:27:32.940 回答