我正在使用一个函数来获取列字段的总数是:
ALTER FUNCTION [dbo].[GetTwoWeeklyWorkTime](@EmployeeID as int,@PayPeriodID as varchar(10))
RETURNS int
AS
BEGIN
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
Select @StartDate=[PeriodStartDate],@EndDate=[PeriodEndDate] from PayPeriod where PayPeriodId=@PayPeriodID
-- Declare the return variable here
DECLARE @ResultVar numeric(10,2)
SELECT @ResultVar=
Sum([WorkingTime])/60
FROM [DayLog] Where EmployeeId =@EmployeeID AND CreatedDate between @StartDate AND @endDate
-- Return the result of the function
RETURN Isnull(@ResultVar,0)
结尾
在线上
Sum([WorkingTime])/60
我得到的结果是int。如何将其转换或转换为数字或浮点数..?
编辑
我试着流动:
Sum(Cast([WorkingTime] as float))/60
Sum([WorkingTime])/60.0
但没有成功。