我要做生产费用的月度汇总表(主页面是a表),首先是费用提取,12个月每个月都可能有提取记录,也可能没有(提取记录存在b表),然后是预算管理,有很多个项目(存在c表),每个预算项目点进去是执行预算,显示的是每个月的提取记录(存在d表),我想做月度汇总表,代码写了感觉不对,麻烦大神帮忙看看,第一张图是想要的效果,第二张是运行的结果。select
e.ORGNAME AS ORGNAME,
CONCAT(CONCAT(a.addyear,'年'),CONCAT(d.`month`,'月')) as nianyue,
b.emonth,
b.removemoney,
d.`month`,
d.payment,
c.bname
from base_safetycost_subject a
LEFT JOIN base_safetycost_extract b ON b.subjectid =a.subjectid
LEFT JOIN base_safetycost_budget c ON c.subjectid=a.subjectid
LEFT JOIN base_safetycost_cost d ON d.budgetid = c.budgetid
LEFT JOIN sys_org e ON e.orgid = a.orgid