dbo.edp_GetNumDaysInMonth()
是用戶定義的函數。分組依據和以ms爲單位的聚合sql
select
month(a.enddatetime),
cast(((dbo.edp_GetNumDaysInMonth(a.enddatetime)) * 22.5 - (isnull(sum(a.delayhr),0)/3600.00))/count(a.machine_no) as decimal(11,2)) as MTBF
from mro_maint a
left join mro_machine b on a.machine_no = b.machine_no
where (b.section = 'TRANSMISSION' OR b.section = 'EATON LINE' OR b.section = 'TOYOTA')
group by month(a.enddatetime)
消息8120,級別16,狀態1,因爲它不是在聚合 函數或GROUP BY子句中包含1號線列「a.enddatetime」在選擇列表中無效 。