0

我有这个查询:我需要将数据库中的百分数值转换为六十进制(分钟)

SELECT 
DISTINCT RD_MAT,
SUM(CASE WHEN RD_PD IN ('421') THEN RD_HORAS ELSE 0 END) AS 'ATRASOS',
SUM(CASE WHEN RD_PD IN ('420') THEN RD_HORAS ELSE 0 END) AS 'FALTAS',
SUM(CASE WHEN RD_PD IN ('084') THEN RD_HORAS ELSE 0 END) AS 'H.EXTRA 100%',
SUM(CASE WHEN RD_PD IN ('080') THEN RD_HORAS ELSE 0 END) AS 'H.EXTRA 50% ',
SUM(CASE WHEN RD_PD IN ('082') THEN RD_HORAS ELSE 0 END) AS 'H.EXTRA NOTURNA' 
FROM SRD020 
INNER JOIN SRV020 ON RD_PD = RV_COD
   AND SRV020.D_E_L_E_T_ <> '*'
   AND SRD020.D_E_L_E_T_ <> '*'
   AND RD_MAT = '000123'
WHERE LEFT(RD_DATPGT,6) = '201304'
GROUP BY RD_MAT

H.EXTRA 100% 的百分数回报率为 16:53。但几分钟后是 16:49。

示例:40 + 40 = 80 的百分位数。40 + 40 = 1:20 六十进制。我需要这个值。

4

2 回答 2

0

所以,看起来你正在做这样的事情。我将转换为 VARCHAR 用于输出目的,您当然不必这样做。

DECLARE @value1 INT, @value2 INT

SET @value1 = 40
SET @value2 = 50

SELECT CAST(FLOOR((@value1+@value2)/60) AS VARCHAR(50)) + ':' +  CAST((@value1+@value2)%60 AS VARCHAR(50))
于 2013-04-24T14:21:22.913 回答
0
Declare @h Varchar(5)='16:53'

Select Cast(DateAdd(SS,CAST(REPLACE(@h,':','.') as Float)*60,0) as Time)

>>> 00:16:31.0000000
于 2013-04-24T14:30:45.737 回答