发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
/*统计各个部门 工资级别为小于2000,2000-3000,3000+的分别为多少 */--使用一下2 张表select * from scott.emp;select * from scott.dept--汇总脚本如下select d.deptno 部门编号, e.level1, e.level2 , e.level3 from (select deptno, count(case when sal < 2000 then 1 else null end) level1, count(case when sal >= 2000 and sal < 3000 then 1 else null end) level2, count(case when sal > 3000 then 1 else null end) level3 from scott.emp group by deptno) e left join scott.dept d on e.deptno = d.deptno
结果如下图:
来自: 老张的菜地 > 《数据库》
0条评论
发表
请遵守用户 评论公约
Oracle分析函数详解
(sal)select deptno,ename,sal, count(*) over(order by sal asc range 3 preceding) 总计。set numformat 9999select ename,sal,avg(sal) over(order by deptno asc rows 2 preceding) avgasc,count(*...
mysql练习(含答案)
select e.ename,m.ename from emp einner join emp m on e.mgr = m.empnowhere e.hiredate select e.ename,m.ename from emp e,emp mwhe...
漫谈oracle中的空值-ORACLE
---- 条 件"sal >any(3000,null)" 等 价 于sal >3000 or sal >null。例 如: SQL >select deptno,sum(sal),sum(comm), sum(sal comm),sum(sal) sum(comm),sum(nvl(sal,0) nvl(co...
Oracle 常用SQL技巧收藏
Sql代码 --低效: SELECT DISTINCT DEPT_NO,DEPT_NAME FROM DEPT D,EMP E WHERE D.DEPT_NO = E.DEPT_NO --高效: SELECT DEPT_NO,DEPT_NAME FROM DEPT D WHERE EXISTS ( SELECT ''X...
尚学堂马士兵Oracle教程 笔记
oracle笔记 之表的管理
Oracle学习 sql基本语法(三)
题: 1.查询工资最低的员工信息 select *from emp where sal=(select min(sal) from emp ); 2. 找到薪水大于本部门平均薪水的员工 select *from emp a1 where sal >(select avg(sal) from e...
Oracle笔记-第1天
select sum(sal) from emp;<1>找员工姓名和直接上级的名字 select ename as 员工姓名,(select ename from emp where empno = a....
1,基础知识点01(19.11.04)
select ename,sal*12 annual_sal from emp;select ename,sal,comm from emp where ename ( not)in (''smith'',''king'',''abc'');select ename,sal,d...
微信扫码,在手机上查看选中内容