这里的代码我试图无济于事。
Select
g.StopCodeName,
AVG(DateDiff(Day, DesiredAppointmentDate,AppointmentDateTime))Case When FollowUpVisitFlag = 'N' THEN ELSE NULL END AS [AvgNewWt]
请注意,我正在尝试通过StopCode对它们进行分组。请帮助!!
答案 0 :(得分:0)
这不是任何DBMS中的有效语法。将CASE
语句移到AVG
聚合
试试这种方式
SELECT g.StopCodeName,
Avg(CASE
WHEN FollowUpVisitFlag = 'N' THEN Datediff(Day, DesiredAppointmentDate, AppointmentDateTime)
ELSE NULL
END) AS [AvgNewWt]