1 having后可以接and
SQL> select deptno from emp group by deptno having deptno=10 and deptno>1;
DEPTNO
----------
10
2 SQL分组前可以使用where,SQL分组后只能用having筛选条件,即:出现group by分组,必须用having才能筛选
SQL> select deptno from emp where sal>100 group by deptno;
DEPTNO
----------
30
20
10
SQL> select deptno from emp group by deptno where sal>100;
select deptno from emp group by deptno where sal>100
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select deptno from emp group by deptno where deptno>1;
select deptno from emp group by deptno where deptno>1
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> select deptno from emp group by deptno having deptno>1;
DEPTNO
----------
30
20
10
温馨提示:答案为网友推荐,仅供参考