case when语句运用
 select b.cur_branch,
count(p.conttract_id),
sum(case when p.aff_date is null then p.payable_money else 0 end),
sum(case when p.aff_date is null and p.fee_item ='租金' then p.payable_money else 0 end),
sum(case when p.aff_date is null and p.fee_item ='电费' then p.payable_money else 0 end),
sum(case when p.aff_date is not null then 1 else 0 end),
sum(case when p.aff_date is null then 1 else 0 end)
from WG_PJHSB p, wg_jzmb b
where p.station_id = b.station_code
group by b.cur_branch
order by b.cur_branch

运用1:sum(case when p.aff_date is null then p.payable_money else 0 end)

累加票据金额

运用2:sum(case when 条件语句l then 1 else 0 end)

累加计数使用。

最新文章

  1. 验证xml是否有效于.dtd文件
  2. 保存会话数据——cookie学习
  3. OC中的消息传递和初始化
  4. mysql 查询随机条记录的sql语句和php计算概率
  5. 工作案件1 一切都是有check引起的
  6. Java之String,StringBuffer,StringBuilder类
  7. POJ_3321_APPLE_TREE
  8. ACM YTU 十进制与八进制的转换 (栈和队列) STL栈调用
  9. android进程间通信:使用AIDL
  10. Ubuntu环境下mysql常见的操作
  11. JAVA(四)类集/枚举
  12. VLC框架分析
  13. 【巷子】---flux---【react】
  14. Innodb引擎状态查看
  15. Django_rest_framework_基础
  16. MAC VNC SSH roo用户开通
  17. div 移动
  18. 关于sleep的理解
  19. C语言ctype.h字符函数和字符串
  20. consider increasing the maximum size of the cache.

热门文章

  1. 关于是用dotnet获取本机IP地址+计算机名的方法
  2. lvs+keeplived笔录
  3. 一种让超大banner图片不拉伸、全屏宽、居中显示的方法
  4. Linux系统中Xampp+Bugfree安装
  5. coffeeScript中类的继承[学习篇]
  6. UICollectionView的使用小记录和一些说明
  7. VirtualBox后台运行虚拟机(无图形界面启动虚拟机)
  8. Async Programming - 1 async-await 糖的本质(1)
  9. 转 strace
  10. Linux文件权限