eg: LeetCode中银行账户概要二题目
写一个 SQL, 报告余额高于 10000 的所有用户的名字和余额. 账户的余额等于包含该账户的所有交易的总和
1 SELECT T1.NAME, 2 SUM(T2.amount) AS balance 3 FROM Users T1 left outer 4 JOIN Transactions T2 5 ON t1.account = t2.account 6 GROUP BY t1.account 7 HAVING SUM(T2.amount)>10000
eg: 查询用户余额大于10000的
SELECT * from user having amount>10000;
SELECT * from user where amount>10000;
两个查询结果是相同的