-
自连接:通过别名,将一张表视为不同别名的多张表。查看全部
-
1、“order by + 数字”的方式排序,最多到2。查看全部
-
子查询注意十项查看全部
-
ORACLE 12C中已经去除行转列函数WM_CONCAT,可使用以下两个函数进行操作 pivot:行转列 unpivot:列转行查看全部
-
要看查看全部
-
create table pm_ci (ci_id varchar2(20), stu_ids varchar2(100)); insert into pm_ci values('1','1,2,3,4'); insert into pm_ci values('2','1,4'); create table pm_stu (stu_id varchar2(20), stu_name varchar2(20)); insert into pm_stu values('1','张三'); insert into pm_stu values('2','李四'); insert into pm_stu values('3','王五'); insert into pm_stu values('4','赵六'); col stu_name for a20; select c.ci_id,wm_concat(s.stu_name) stu_name from pm_ci c,pm_stu s where instr(c.stu_ids,s.stu_id)>0 group by c.ci_id;查看全部
-
层次查询, select level, ** from tb connect by prior XX isn ull order by level查看全部
-
berak on deptno skip 2 group by rollup(a,b)查看全部
-
SELECT * FROM ( SELECT rownum r, e.empno, e.ename, e.sal FROM (SELECT * from emp ORDER BY sal DESC) e) WHERE r>=5 AND r<=8 ;查看全部
-
a!=null,永远是假的查看全部
-
not in (<>all)查看全部
-
select c.ci_id,wm_concat(s.stu_name) from pm_ci c,pm_stu s where instr(c.stu_ids,s.stu_id)>0 group by ci_id查看全部
-
案例二: --查询本部门薪水大于平均工资的员工;(使用表连接查询) 相关子查询: 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 e.empno,e.ename,e.sal,d.avgsal from emp e,(select deptno,avg(sal) avgsal from emp group by deptno) d where e.deptno=d.deptno and e.sal>d.avgsal 相关子查询比多表查询占用cpu少查看全部
-
感觉最里层那个rownum没有什么作用, 其实这样的就可以查出来 SELECT * FROM ( SELECT rownum r, e.empno, e.ename, e.sal FROM (SELECT * from emp ORDER BY sal DESC) e) WHERE r>=5 AND r<=8 ;查看全部
-
相关子查询: 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); 找出员工薪水大于本部门的平均薪水的员工查看全部
举报
0/150
提交
取消