Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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) ?
您不需要按聚合列分组。你需要的是
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