SELECT TOP 10 sum(CoalPowderHeat/7000*(CoalPowderlConsumption+coalPowderlConsumptionModify)) as coal
FROM dbo.[MonthReport]
LEFT JOIN PL_SITE ON MonthReport.factoryKey = PL_SITE.OBJECT_KEY
LEFT JOIN PL_CELL ON MonthReport.prodLineKey = PL_CELL.DCS_NUMBER
WHERE convert(varchar(7),ReportDate,23)= '${left(MONTHDELTA(TODAY(), -1),7)}'
GROUP BY
PL_CELL.CELL_NUMBER order by coal
SELECT top 10 PL_CELL.CELL_NUMBER,min(coal) coal from
(SELECT PL_CELL.CELL_NUMBER,产线字段,sum(CoalPowderHeat/7000*(CoalPowderlConsumption+coalPowderlConsumptionModify)) as coal
FROM dbo.[MonthReport]
LEFT JOIN PL_SITE ON MonthReport.factoryKey = PL_SITE.OBJECT_KEY
LEFT JOIN PL_CELL ON MonthReport.prodLineKey = PL_CELL.DCS_NUMBER
WHERE convert(varchar(7),ReportDate,23)= '${left(MONTHDELTA(TODAY(), -1),7)}'
GROUP BY
PL_CELL.CELL_NUMBER,产线字段) t
group by PL_CELL.CELL_NUMBER
order by coal
故事的小黄瓜(提问者)SELECT top 10 PL_CELL.CELL_NUMBER,min(coal) coal from
(SELECT PL_SITE.SITE_NUMBER,PL_CELL.CELL_NUMBER,sum(CoalPowderHeat/7000*(CoalPowderlConsumption+coalPowderlConsumptionModify)) as coal
FROM dbo.[MonthReport]
LEFT JOIN PL_SITE ON MonthReport.factoryKey = PL_SITE.OBJECT_KEY
LEFT JOIN PL_CELL ON MonthReport.prodLineKey = PL_CELL.DCS_NUMBER
WHERE convert(varchar(7),ReportDate,23)= \'${left(MONTHDELTA(TODAY(), -1),7)}\'
GROUP BY
PL_SITE.SITE_NUMBER,PL_CELL.CELL_NUMBER) t
group by PL_CELL.CELL_NUMBER
order by coal
您的意思是上面这样吗?PL_SITE.SITE_NUMBER是公司字段,PL_CELL.CELL_NUMBER是产线字段,但是说数据集配置错误