当试图从一张桌子操纵和显示日期时,我很难正确编码。
我需要从同一张表中找到每天完成的服务量(已完成,基于ServiceId计数)。然后我需要找到OverallCharge(已完成)并找到每天这些overallCharge(s)的最小值,最大值和平均值(BasicCharge + AdditionalPartsCharge + AdditionalLabourCharge)
我需要在表
中显示每个ServiceDate的这些费用我的草稿如下,但告诉我ServiceId不是聚合函数的一部分。
SELECT Service.ServiceDate, Service.NumServices , Min(OverallCharge) AS MinOverallCharge, Max(OverallCharge) AS MaxOverallCharge, Avg(OverallCharge) AS AverageOverallCharge FROM (SELECT Service.ServiceId, Sum([BasicCharges]+[AdditionalLabourCharges]+[AdditionalPartCharges]) AS OverallCharge, Service.ServiceDate, Count (Service.ServiceId) AS NumServices FROM Service GROUP BY Service.ServiceDate, NumServices, MinOverallCharge, MaxOverallCharge, AvgerageOverallCharge);
由于