發(fā)文章
發(fā)文工具
撰寫
網(wǎng)文摘手
文檔
視頻
思維導(dǎo)圖
隨筆
相冊
原創(chuàng)同步助手
其他工具
圖片轉(zhuǎn)文字
文件清理
AI助手
留言交流
/*統(tǒng)計各個部門 工資級別為小于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
結(jié)果如下圖:
來自: 老張的菜地 > 《數(shù)據(jù)庫》
0條評論
發(fā)表
請遵守用戶 評論公約
Oracle分析函數(shù)詳解
(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練習(xí)(含答案)
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...
尚學(xué)堂馬士兵Oracle教程 筆記
oracle筆記 之表的管理
Oracle學(xué)習(xí) 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,基礎(chǔ)知識點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...
微信掃碼,在手機(jī)上查看選中內(nèi)容