id, create_user_id, create_date, update_user_id, maintenance_company_id, maintenance_company_name, section_id, section_name, file_name, file_url, update_date, del_flg, remark
SELECT
te.maintenance_company_id,
te.maintenance_company_name,
te.section_id,
te.section_name,
COUNT(*) as trainCount
FROM
T_Sec_Training_Education te
WHERE
te.del_flg = 0
and te.maintenance_company_id=#{train.maintenanceCompanyId}
and te.section_id=#{train.sectionId}
and date_format(te.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{train.startTime},'%Y-%m'),'%Y-%m')
and date_format(te.create_date,'%Y') = date_format(STR_TO_DATE(#{train.startTime},'%Y'),'%Y')
group by te.maintenance_company_id,
te.maintenance_company_name,
te.section_id,
te.section_name
SELECT
count(*) as centerTrainCount
FROM
T_Pub_Train t
WHERE
type = 2
and delete_flag=0
and date_format(t.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{centerTrain.startTime},'%Y-%m'),'%Y-%m')
and date_format(t.create_date,'%Y') = date_format(STR_TO_DATE(#{centerTrain.startTime},'%Y'),'%Y')
select
count(*) as mTrainCount
from
T_Sec_Training_Education ts
where
ts.del_flg=0
and date_format(ts.create_date,'%Y-%m') = date_format(STR_TO_DATE(#{allCount.startTime},'%Y-%m'),'%Y-%m')
and date_format(ts.create_date,'%Y') = date_format(STR_TO_DATE(#{allCount.startTime},'%Y'),'%Y')
and ts.maintenance_company_id=#{allCount.maintenanceCompanyId}
SELECT
s.id as sectionId,
s.section_name as sectionName,
m.id as maintenanceCompanyId,
m.maintenance_company_name as maintenanceCompanyName,
IFNULL
(b.sumCount,0) AS sumCount
FROM
T_Lhzx_Section s
LEFT JOIN T_Lhzx_Road_Section_Maintenance_Company rsmc ON s.id = rsmc.section_id
LEFT JOIN T_Lhzx_Maintenance_Company m ON m.id = rsmc.maintenance_company_id
LEFT JOIN (
SELECT
section_id,
section_name,
maintenance_company_id,
maintenance_company_name,
COUNT(id) as sumCount
FROM
T_Sec_Training_Education
WHERE
del_flg = 0
and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
GROUP BY
section_id,
section_name,
maintenance_company_id,
maintenance_company_name
order by
section_id,
maintenance_company_id) b ON rsmc.section_id = b.section_id
AND rsmc.maintenance_company_id = b.maintenance_company_id
WHERE
m.id IS NOT NULL
AND rsmc.section_id = #{sectionId}
AND rsmc.maintenance_company_id = #{maintenanceCompanyId}
GROUP BY
s.id,
s.section_name,
m.id,
m.maintenance_company_name,
b.sumCount
ORDER BY
s.id,
m.id
select
sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount
from
( ) temp
SELECT
section_id,
section_name,
maintenance_company_id,
maintenance_company_name,
COUNT(id) as sumCount
FROM
T_Sec_Training_Education
WHERE
del_flg = 0
AND section_id = #{sectionId}
AND maintenance_company_id = #{maintenanceCompanyId}
and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
GROUP BY
section_id,
section_name,
maintenance_company_id,
maintenance_company_name
order by
section_id,
maintenance_company_id