有几种方法可以做到这一点。
您可以在更新中设置值时强制转换:
update T1 set T1.fm_hour = cast(T2.fm_hour as float)
from T T1
join
(
Select distinct name, sum(fm) over (partition by name)/60 fm_hour
from T
) T2 on T1.name = T2.name
where T1.work_type = 'out'
或者可以投60:
update T1 set T1.fm_hour = T2.fm_hour
from T T1
join
(
Select distinct name, sum(fm) over (partition by name)/ cast(60 as float) fm_hour
from T
) T2 on T1.name = T2.name
where T1.work_type = 'out'
或者你可以只除以 60.0:
update T1 set T1.fm_hour = T2.fm_hour
from T T1
join
(
Select distinct name, sum(fm) over (partition by name)/ 60.0 fm_hour
from T
) T2 on T1.name = T2.name
where T1.work_type = 'out'