DistributionStatsMinidaoDao_distributionStatsData.sql 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <#if (distributionEntity.attType)?? && distributionEntity.attType != 0>
  2. SELECT deptId ,departname ,peopleNum ,
  3. convert(peopleNum/peopletotal*100,decimal(10,2)) proportion
  4. FROM
  5. (
  6. </#if>
  7. SELECT cds.yearmonth yearmonth , cds.postid deptId, d.post_name departname ,
  8. <#if (distributionEntity.attType)?? && distributionEntity.attType != 0>
  9. round(avg(cds.people_num)) peopleNum ,
  10. (
  11. SELECT SUM(peopleNum) peopletotal from (
  12. SELECT cds.yearmonth yearmonth , cds.postid deptId, d.post_name departname ,
  13. round(avg(cds.people_num)) peopleNum
  14. from t_bus_compost_distribution_statistics cds
  15. LEFT JOIN t_bus_post d
  16. ON cds.postid = d.ID
  17. where 1=1
  18. <#if (distributionEntity.attType)?? && distributionEntity.attType == 2>
  19. and cds.yearmonth like CONCAT('%', :distributionEntity.attYear ,'%')
  20. </#if>
  21. <#if (distributionEntity.attType)?? && distributionEntity.attType != 2>
  22. <#if ( distributionEntity.yearMonthList )?? && distributionEntity.yearMonthList ?size gt 0>
  23. and cds.yearmonth in(
  24. <#list distributionEntity.yearMonthList as item>
  25. '${item}'
  26. <#if item_has_next>,</#if>
  27. </#list>
  28. )
  29. </#if>
  30. </#if>
  31. GROUP BY cds.postid
  32. ) a
  33. ) peopletotal
  34. </#if>
  35. <#if (distributionEntity.attType)?? && distributionEntity.attType == 0>
  36. cds.people_num peopleNum , cds.proportion proportion
  37. </#if>
  38. from t_bus_compost_distribution_statistics cds
  39. LEFT JOIN t_bus_post d
  40. ON cds.postid = d.ID
  41. where 1=1
  42. <#if (distributionEntity.attType)?? && distributionEntity.attType == 2>
  43. and cds.yearmonth like CONCAT('%', :distributionEntity.attYear ,'%')
  44. </#if>
  45. <#if (distributionEntity.attType)?? && distributionEntity.attType != 2>
  46. <#if ( distributionEntity.yearMonthList )?? && distributionEntity.yearMonthList ?size gt 0>
  47. and cds.yearmonth in(
  48. <#list distributionEntity.yearMonthList as item>
  49. '${item}'
  50. <#if item_has_next>,</#if>
  51. </#list>
  52. )
  53. </#if>
  54. </#if>
  55. <#if (distributionEntity.attType)?? && distributionEntity.attType != 0>
  56. GROUP BY cds.postid
  57. ) a
  58. </#if>