case函数 (适合区间,>,<判断)
   case when 判断表达式 then
        when 判断表达式 then
        .....
   end
 
  select deptno,count(*) total,
   sum(case when sal>=2000 then 1
       end) great,
   sum(case when sal<2000 then 1
       end) least
  from emp
  where deptno is not null
  group by deptno;
 
//统计部门中男人数和女人数
 create table j20(
  id number(7),
  name varchar(20),
  sex char(1), --'M'或'F'
  deptno number(7));
 
 select deptno,
        sum(decode(sex,'M',1,0)) as male,
        sum(decode(sex,'F',1,0)) as female
 from j20
 group by deptno;
 
 select deptno,
        sum(case when sex='M' then 1
            else 0 end) as male,
        sum(case when sex='F' then 1
            else 0 end) as female
 from j20
 group by deptno;
 //基于EMP表查询部门编号,工资1000以内人数,
 1000-2000人数,2000以上人数
 select deptno,
    sum(case when sal<1000 then 1
             else 0
        end) "1000以内",
    sum(case when sal>=1000 and sal<2000 then 1
             else 0
        end) "1000-2000",
    sum(case when sal>=2000 then 1
             else 0
        end) "2000以上"
 from emp
 group by deptno;
 
 //查询调薪结果,规则:MANAGER涨10%,CLERK涨20%,
  其他人涨5%
 select empno,ename,job,sal,
        decode(job,'MANAGER',sal*1.1,
                   'CLERK',sal*1.2,
                   sal*1.05) "加薪之后"
 from emp;

最新文章

  1. createjs学习二之flash转canvas学习1
  2. python导入opencv解决no module named cv2问题
  3. JUC.Condition学习笔记[附详细源码解析]
  4. 那些年我们一起过的JS闭包,作用域,this,让我们一起划上完美的句号。
  5. 【LeetCode】389 Find the Difference(java)
  6. python编程关键字
  7. 【翻译十五】-java并发之固定对象与实例
  8. Java可变参数讲解
  9. C#基础--局部类型Partial
  10. 学习css3中的动画
  11. selenium+BeautifulSoup实现强大的爬虫功能
  12. 创建maven项目pom.xml第一行报错
  13. Vue-生命周期图示 注解
  14. c#Socket服务器与客户端的开发(1)
  15. erlang证书加密
  16. golang context
  17. Nancy.Net之旅-初次见面
  18. ApplicationListener详解
  19. PCLVisualizer可视化类
  20. 【前端开发工具】WijmoJS 2018 v3 正式发布,全面支持Angular7

热门文章

  1. volatile可见性和指令重排
  2. 02springMVC理解DispatcherServlet
  3. 网络抓包工具 Fiddler
  4. scikit-learn系列之如何存储和导入机器学习模型
  5. 利用flashback transaction query新特性进行事务撤销
  6. 解决:[WARNING] fpm_children_bury(), line 215: child 2736 (pool default) exited on signal 15 SIGTERM after 59.588363 seconds from start
  7. CLR - 设计类型
  8. iOS 内网内测应用发布
  9. pgpool中的配置参数的定义
  10. 订购一套Arduino UNO r3入门套件