如果总小时数是00:00那么我如何获得或转换为00:01

时间:2018-01-25 06:18:17

标签: python-2.7 sql-server-2008 pyodbc

我能够获得总小时但我想如果计数是00:00输出应该是00:01

这是我的疑问。

SELECT reviews.id as review_id, COALESCE( name, 'N/A' )
FROM customers, reviews
WHERE customers.id = reviews.customer_id

1 个答案:

答案 0 :(得分:0)

使用大小写尝试此查询:

SELECT 
CASE CONVERT(varchar(3),DATEDIFF(minute,MIN(clock), MAX (clock))/60) + ':' + RIGHT('0' + CONVERT(varchar(2),DATEDIFF(minute,MIN (clock),MAX (clock))%'60'),2) 
WHEN '0:00' THEN '00:01'
ELSE CONVERT(varchar(3),DATEDIFF(minute,MIN(clock), MAX (clock))/60) + ':' + RIGHT('0' + CONVERT(varchar(2),DATEDIFF(minute,MIN (clock),MAX (clock))%'60'),2) 
END
as TotalHours