FUNCTION fun_GetDateDIff(@startDatedatetime,@endDatedatetime)
returnsintASBEGINreturndatediff(month,@startDate,@endDate);
ENDGOselect ProductID,sum(LineTotal) from Purchasing.PurchaseOrderDetail where dbo.fun_GetDateDIff(DueDate,getdate())=142/**/groupby ProductID --查询前的142的数据View Code