<#if (distributionEntity.attType)?? && distributionEntity.attType != 0> SELECT yearmonth,deptId,departname,peopleNum, IFNULL(CONVERT(peopleNum/totalNum*100,decimal(16,2)),0) proportion FROM ( SELECT cds.yearmonth yearmonth , cds.postid deptId, d.post_name departname , <#if (distributionEntity.attType)?? && distributionEntity.attType != 0> round(avg(people_num)) peopleNum, ( SELECT SUM(total) peopletotal from ( SELECT round(avg(people_num)) total from t_bus_projpost_distribution_statistics cds LEFT JOIN t_bus_post d ON cds.postid = d.ID where 1=1 and cds.pjt_id =:distributionEntity.pid <#if (distributionEntity.attType)?? && distributionEntity.attType == 2> and cds.yearmonth like CONCAT('%', :distributionEntity.attYear ,'%') <#if (distributionEntity.attType)?? && distributionEntity.attType != 2> <#if ( distributionEntity.yearMonthList )?? && distributionEntity.yearMonthList ?size gt 0> and cds.yearmonth in( <#list distributionEntity.yearMonthList as item> '${item}' <#if item_has_next>, ) GROUP BY cds.postid ) a ) totalNum <#if (distributionEntity.attType)?? && distributionEntity.attType == 0> cds.people_num peopleNum , cds.proportion proportion from t_bus_projpost_distribution_statistics cds LEFT JOIN t_bus_post d ON cds.postid = d.ID where 1=1 <#if (distributionEntity.attType)?? && distributionEntity.attType == 2> and cds.yearmonth like CONCAT('%', :distributionEntity.attYear ,'%') <#if (distributionEntity.attType)?? && distributionEntity.attType != 2> <#if ( distributionEntity.yearMonthList )?? && distributionEntity.yearMonthList ?size gt 0> and cds.yearmonth in( <#list distributionEntity.yearMonthList as item> '${item}' <#if item_has_next>, ) <#if (distributionEntity.pid)??> and cds.pjt_id =:distributionEntity.pid <#if (distributionEntity.attType)?? && distributionEntity.attType != 0> GROUP BY cds.postid )a