0

我有一个表 tblTimesheet,我在其中存储用户计时 hr。像这样

Hours
4.01
3.44
0.05
0.04
2.40

我想要的是我正在使用的这些时间段中的一些

select sum(hours) from tbltimesheets where workDate='2012-08-30 00:00:00.000' and taskid in (86,3,34)

但它给了我 9.94,我想像 10.34 一样得到它,数据类型是这个字段的十进制

请帮帮我

提前致谢

4

2 回答 2

1

像这样的东西怎么样

DECLARE @Table TABLE(
        Hrs FLOAT
)
INSERT INTO @Table SELECT 4.01 
INSERT INTO @Table SELECT 3.44 
INSERT INTO @Table SELECT 0.05 
INSERT INTO @Table SELECT 0.04 
INSERT INTO @Table SELECT 2.40

;WITH Vals AS (
        SELECT  SUM(FLOOR(Hrs)) NumHrs,
                SUM((Hrs - FLOOR(Hrs)) * 100) NumMins 
        FROM    @Table
)
SELECT  NumHrs + FLOOR(NumMins / 60) + ((NumMins / 60 - FLOOR(NumMins / 60)) * 60 / 100)
FROM    Vals
于 2012-09-05T05:54:09.943 回答
0
 first hours conet to minute and last step divide by 60.
select (sum(hours*60)/60) from tbltimesheets where workDate='2012-08-30 00:00:00.000' and taskid in (86,3,34)
于 2012-09-05T05:40:21.073 回答