select t.DEPT_ID PARENT_ID,count(s.senduserorg) num
from(selectdistinct DEPT_ID
from"FILETRANSFER"."sys_dept"where DEPT_ID BETWEEN'103'and'115') t
leftjoin(selectdistinct PARENT_ID, DEPT_ID
from"FILETRANSFER"."sys_dept"where PARENT_ID BETWEEN103and115) a
on t.DEPT_ID = a.PARENT_ID
leftjoin(select*from"FILETRANSFER"."tb_sendtelegram"whereyear(sendtime)=YEAR(NOW())) s
on a.DEPT_ID = s.senduserorg
groupby t.DEPT_ID;
自动生成 ID
DM
select sys_guid()from dual
<selectKeykeyProperty="id"resultType="java.lang.String"order="BEFORE">
select sys_guid() from dual
</selectKey>
MySQL
selectreplace(uuid(),'-','')from dual
<selectKeykeyProperty="id"resultType="java.lang.String"order="BEFORE">
select replace(uuid(),'-','') from dual
</selectKey>