SELECT
p.project_id as projectId,
p.project_name AS projectName,
COALESCE(SUM(ci.fitted_capacity),0) AS value
FROM
ees_project p
LEFT JOIN (
SELECT
cit.project_id,
cit.fitted_capacity,
cit.created_date
FROM
ees_project_cities cit
WHERE
cit.del_flag = #{delFlag}
) ci ON p.project_id = ci.project_id
WHERE
p.del_flag = #{delFlag}
<if test="startDate!=null"> AND ci.bill_date >=#{startDate}</if>
<if test="endDate!=null"> AND ci.bill_date <=#{endDate}</if>
GROUP BY p.project_name, p.project_id
ORDER BY COALESCE(SUM(ci.fitted_capacity),0) DESC
mybatis根据类目统计某项值sql
最新推荐文章于 2023-07-02 09:47:39 发布