SELECT u.realname username,w.pjt_id pid,d.departname pName,d1.departname pidName,w.yearmonth,w.wage_pay_total wagePayTotal
from t_bus_user_wage_statistics w
LEFT JOIN t_s_depart d
ON w.pjt_id = d.ID
LEFT JOIN t_s_depart d1
ON w.dept_id = d1.ID
LEFT JOIN t_s_base_user u
ON w.user_id = u.id
where 1=1
<#if ( wageEntity.yearMonthList )?? && wageEntity.yearMonthList ?size gt 0>
			and w.yearmonth in(
			<#list wageEntity.yearMonthList as item>        
			   '${item}'
			 <#if item_has_next>,</#if>
			 </#list>
			)
</#if>
<#if (wageEntity.pid)??>
		 and w.pjt_id =:wageEntity.pid
</#if>
<#if (wageEntity.pid)??>
		 and w.dept_id =:wageEntity.did
</#if>

order by wagePayTotal desc