mysql> select open_emp_id,count(*) how_many
-> from account
-> group by open_emp_id;
+-------------+----------+
| open_emp_id | how_many |
+-------------+----------+
| 1 | 8 |
| 10 | 7 |
| 13 | 3 |
| 16 | 6 |
+-------------+----------+
4 rows in set
///组合就意味着Group by,根据指定的列进行排名,选择指定的列。
查找至少包含一个账户的产品和支行组合的可用余额的合计数,并根据余额合计说对结果进行排序。
select product_cd,open_branch_id,sum(aval_balance)
group by product_cd,open_branch_id
having count(*)>1
order by 3 desc