- 论坛徽章:
- 0
|
谢谢回复!
刚刚总结了一下,大家看看有没有错的:对db2
select dept, avg(salary) from staff group by dept having salary>10000…….wrong
select dept, salary from staff group by dept having salary>10000………….wrong
select dept, avg(salary) from staff group by dept having avg(salary)>10000…….ok
select comm , avg(salary) from staff group by comm having comm>1000………..ok
select dept , avg(salary) from staff group by dept having max(comm)>1000…….ok
1。跟groupby时select中未用column function的column必须放在group by中。
2。having字句中:
1)group by中出现过的column:可直接放
2)group by中未出现过的column:必须放在column function中 |
|