DbQueryUserMiniDao_queryUserByGender.sql 872 B

1234567891011121314151617181920212223
  1. select count(baseuu.realname) as total,
  2. count(uu3.id)as maleCount,
  3. count(uu4.id)as femaleCount,
  4. :inDto.inMonth as inMonth,
  5. dp.glcname as departname
  6. from t_bus_user_personnel pers
  7. LEFT JOIN t_s_base_user baseuu on baseuu.id = pers.userid
  8. left join t_s_user_org uorg on uorg.user_id = pers.userid and uorg.ifpluralism = '0'
  9. left join t_s_user uu on baseuu.id = uu.id
  10. left join t_s_depart dp on dp.ID = uorg.org_id
  11. left join t_s_user uu3 on baseuu.id = uu3.id and uu3.gender = '0'
  12. left join t_s_user uu4 on baseuu.id = uu4.id and uu4.gender = '1'
  13. where (pers.leave_date is null
  14. <#if inDto.inMonth ?exists && inDto.inMonth ?length gt 0>
  15. OR pers.leave_date > :inDto.inMonth
  16. </#if>
  17. )
  18. <#if inDto.inMonth ?exists && inDto.inMonth ?length gt 0>
  19. AND pers.contract_stime <= :inDto.inMonth
  20. </#if>
  21. and baseuu.delete_flag = '0' and dp.glcname is not null
  22. GROUP BY dp.glcname