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') ");