故事的小黄瓜(提问者)SELECT DailyReport.OBJECT_KEY,DailyReport.ApprovalResult,DailyReport.factoryKey,DailyReport.ReportDate,DailyReport.ClinkerYeildDay,DailyReport.ClinkerYeildPlan,DailyReport.ClinkerYeildDayUpdate,PL_SITE.SITE_NUMBER,PL_SITE.SITE_NAME,PL_CELL.CELL_NAME,PL_CELL.CELL_NUMBER,PM_PLAN.ClinkerYield FROM dbo.[DailyReport] LEFT JOIN PL_SITE ON DailyReport.factoryKey = PL_SITE.OBJECT_KEY LEFT JOIN PL_CELL ON DailyReport.ProdLineCode = PL_CELL.DCS_NUMBER LEFT JOIN PM_PLAN ON DailyReport.ProdLineCode = PM_PLAN.MaterielCode where ApprovalLevel=2
${if(type=\'month\', \" and cast(month(dbo.[DailyReport].ReportDate) as int) = \"+ 月 + \" and year(dbo.[DailyReport].ReportDate) = \'\" + 年 +\"\'\", \"\")}
${if(len(公司名称) == 0,\"\",\" and SITE_NUMBER in (\'\" + 公司名称 + \"\')\")}