-
where寫在select * from *語句之后,其他組函數(shù)之前 having語句反之 從sql優(yōu)化角度來看,where更效率更高,先過濾后分組查看全部
-
select column, group func from table [where condition] [group by column] [having condition] [order by column]查看全部
-
select語句中沒有出現(xiàn)在主函數(shù)的字段,則必出現(xiàn)在group by子句, 反之,不成立查看全部
-
select deptno,avg(sal) from emp group by deptno查看全部
-
nvl()函數(shù)忽略空值函數(shù),參數(shù)一非空則返回原值,為空值則返回參數(shù)二查看全部
-
select deptno,wm_concat(ename) from emp group by deptno;查看全部
-
avg/sum/min/max/count/wm_concat查看全部
-
自己寫的代碼: select * from emp e,(select deptno,avg(sal) avgsal from emp group by deptno) d where e.sal>d.avgsal and e.deptno=d.deptno 老師的代碼: select empno,ename,sal,(select avg(sal) from emp where deptno=e.deptno) avgsal from emp e where sal>(select avg(sal) from emp where deptno=e.deptno);查看全部
-
select * from (select * from emp order by sal desc) where rownum<=3查看全部
-
示例一: select * from (select empno,ename,sal from emp); 示例二: select * from (select empno,ename,sal,12*sal 年薪 from emp);查看全部
-
group by后面不能跟子查詢!查看全部
-
where select having from 都可以使用子查詢查看全部
-
子查詢需要注意的問題 不要忘記子查詢語法中的小括號 形成良好的子查詢的書寫風(fēng)格 可以使用子查詢的位置:Where,select,having,from 不可以使用子查詢的位置:group by 強(qiáng)調(diào):from后面的子查詢 主查詢和子查詢可以不是一張表 一般不在自查詢中,使用排序;但是在Top-N分析問題中,必須對子查詢排序 一般先執(zhí)行子查詢,再執(zhí)行主查詢;但相關(guān)子查詢例外 單行子查詢只能使用單行操作符;多行子查詢只能多行操作符 注意:子查詢中是Null值的問題查看全部
-
子查詢的問題續(xù)查看全部
-
子查詢的問題查看全部
舉報(bào)
0/150
提交
取消