Sql查询问题'BatchRelease.BatchReleaseNo'在选择列表中无效

时间:2015-02-11 15:08:40

标签: sql sql-server

在下面的查询中,当我执行它时抛出错误“Column'Batch'Release.BatchReleaseNo'在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。”请我解决这个问题。当我对这些值求和时会出现这个错误。

SELECT DISTINCT BR.BatchReleaseNo,BR.CreatedOn,P.ProductName,
        BRD.BatchReleaseQuantity,P.ProductCode,BOED.NoOfEmployee,
        BOED.TimeInHours,EM.EmployeeType,BRPD.ProcessLoss,
        MP.UnitProcessTime,MM.RequiredCostPerHour,
        MM.MachineryType,
        (BRD.BatchReleaseQuantity*BRD.UnitPrice) AS BatchCompletionValue,
        ISNULL(
               SUM((BOED.NoOfEmployee
                    *(BOED.TimeInHours/60 )/60)
                    *(EM.CostPerDay/EM.WorkingHours))
               ,0.0
              )

         FROM BatchReleaseDetails BRD 
        LEFT OUTER JOIN BatchRelease BR ON BR.BatchReleaseID=BRD.BatchReleaseID
        LEFT OUTER JOIN Product P ON P.ProductID=BRD.ProductID
        LEFT OUTER JOIN BatchOrderEmployeeDetails BOED ON BOED.BatchReleaseID=BR.BatchReleaseID
        LEFT OUTER JOIN EmployeeMaster EM ON EM.EmployeeTypeID=BOED.EmployeeTypeID
        LEFT OUTER JOIN BatchReleasedProcessDetails BRPD ON BRPD.BatchReleaseID=BR.BatchReleaseID
        --LEFT OUTER JOIN Process PR ON PR.ProcessID=BRPD.ProcessID
        LEFT OUTER JOIN MachineProcess MP ON MP.ProcessID=BRPD.ProcessID
        LEFT OUTER JOIN MachineMaster MM ON  MM.MachineID=MP.MachineID
        GRoup BY BR.BatchReleaseNo

0 个答案:

没有答案