myql case when

count(case when wait<0  then agent_id end)


例如:

StringBuffer strSql = new StringBuffer();
		strSql.append(" select agent_id ,agent_code,agent_name, finish_date , ");
		strSql.append(" count(case when file_name='a' and finish_flag=1  then file_name end) as 'finish_a',  ");
		strSql.append(" count(case when file_name='b' and finish_flag=1  then file_name end) as 'finish_b', ");
		strSql.append(" count(case when file_name='c' and finish_flag=1  then file_name end) as 'finish_c', ");
		strSql.append(" count(case when file_name='d' and finish_flag=1  then file_name end) as 'finish_d', ");
		strSql.append(" count(case when file_name='a' and finish_flag=0  then file_name end) as 'unfinish_a', ");
		strSql.append(" count(case when file_name='b' and finish_flag=0  then file_name end) as 'unfinish_b', ");
		strSql.append(" count(case when file_name='c' and finish_flag=0  then file_name end) as 'unfinish_c', ");
		strSql.append(" count(case when file_name='d' and finish_flag=0  then file_name end) as 'unfinish_d', ");
		strSql.append(" (count(case when file_name='a' and finish_flag=1  then file_name end)+count(case when file_name='a' and finish_flag=0  then file_name end)) as a_all,");
		strSql.append(" (count(case when file_name='b' and finish_flag=1  then file_name end)+count(case when file_name='b' and finish_flag=0  then file_name end)) as b_all,");
		strSql.append(" (count(case when file_name='c' and finish_flag=1  then file_name end)+count(case when file_name='c' and finish_flag=0  then file_name end)) as c_all,");
		strSql.append(" (count(case when file_name='d' and finish_flag=1  then file_name end)+count(case when file_name='d' and finish_flag=0  then file_name end)) as d_all,");
		strSql.append(" count(case when file_name='a' and finish_flag=1  then file_name end)/(count(case when file_name='a' and finish_flag=1  then file_name end)+count(case when file_name='a' and finish_flag=0  then file_name end)) as a_rate, ");
		strSql.append(" count(case when file_name='b' and finish_flag=1  then file_name end)/(count(case when file_name='b' and finish_flag=1  then file_name end)+count(case when file_name='b' and finish_flag=0  then file_name end)) as b_rate, ");
		strSql.append(" count(case when file_name='c' and finish_flag=1  then file_name end)/(count(case when file_name='c' and finish_flag=1  then file_name end)+count(case when file_name='c' and finish_flag=0  then file_name end)) as c_rate, ");
		strSql.append(" count(case when file_name='d' and finish_flag=1  then file_name end)/(count(case when file_name='d' and finish_flag=1  then file_name end)+count(case when file_name='d' and finish_flag=0  then file_name end)) as d_rate ");
		strSql.append("  from v_publish_log where date(finish_date) = '"+strDate+"' and  file_name in ('a','b','c','d')  ");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值