• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
james1207

博客园    首页    新随笔    联系   管理    订阅  订阅

sum(case when then)(男女生的个数)

 判断类似一个班级的男生和女生的人数,用sum (cese when then )

 

select count(er.execute_result),
sum(case er.execute_result   when 1 then  1  else  0 end) completed,
sum(case er.execute_result    when 0 then     1    else    0   end) notCompleted
  from taw_wp_execute_result er ;


 

select 
(case when er.execute_result>0 then 'a'
 else 'b'
  end 
)
from taw_wp_execute_result er ;


 

posted @ 2013-09-09 19:59  Class Xman  阅读(440)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3