In my database, I have a table with a column of type Float
which represents the total work hours. I have to sum this value over all rows.
I can't use sum function, because 08.03 = 08 hour, 03 minute.
For example:
00.55 + 00.51=> 01.06
but I want
00.55 + 00.51 => 01.46
My query
Declare @TEMP1 table (TotalHours float)
insert into @TEMP1(TotalHours)
select ol.HrWork TotalHours
from OTLog ol
where EmployeeId = 2048
Declare @attCount int
Declare @attSum int
set @attSum = 0;
set @attCount = (select count(*) from @TEMP1)
print @attCount
while (@attCount <> 0)
begin
set @attSum = @attSum + (select Top 1 (LEFT(TotalHours,1)*60)+(RIGHT(TotalHours,2)) TotalHours from @TEMP1);
delete top(1) from @TEMP1;
set @attCount = @attCount - 1;
print @attSum;
end
print @attSum
select *
from OTLog
where EmployeeId = 2048
Any thoughts would be appreciated.