<#if (distributionEntity.attType)?? && distributionEntity.attType != 0> SELECT deptId ,departname ,peopleNum , convert(peopleNum/peopletotal*100,decimal(10,2)) proportion FROM ( SELECT cds.yearmonth yearmonth , cds.postid deptId, d.post_name departname , <#if (distributionEntity.attType)?? && distributionEntity.attType != 0> round(avg(cds.people_num)) peopleNum , ( SELECT SUM(peopleNum) peopletotal from ( SELECT cds.yearmonth yearmonth , cds.postid deptId, d.post_name departname , round(avg(cds.people_num)) peopleNum from t_bus_compost_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>, ) GROUP BY cds.postid ) a ) peopletotal <#if (distributionEntity.attType)?? && distributionEntity.attType == 0> cds.people_num peopleNum , cds.proportion proportion from t_bus_compost_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.attType)?? && distributionEntity.attType != 0> GROUP BY cds.postid ) a