首页 > 代码库 > oracle where与having
oracle where与having
where与having可以过滤,一般来说尽量使用where ,但是如果过滤条件中有组函数,只能使用having
1 SQL> select deptno,avg(sal) 2 2 from emp 3 3 where deptno=10 4 4 group by deptno; 5 6 DEPTNO AVG(SAL) 7 ------ ---------- 8 10 2950 9 10 SQL> 11 SQL> select deptno,avg(sal)12 2 from emp13 3 where avg(sal)>200014 4 group by deptno;15 16 select deptno,avg(sal)17 from emp18 where avg(sal)>200019 group by deptno20 21 ORA-00934: 此处不允许使用分组函数22 23 SQL> 24 SQL> select deptno,avg(sal)25 2 from emp26 3 group by deptno27 4 having avg(sal)>2000;28 29 DEPTNO AVG(SAL)30 ------ ----------31 20 2258.3333332 10 2950
oracle where与having
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。