Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Soma da diferença de DateTime no sql (HH.MM)


Faça a soma antes da formatação
SELECT
  ATM,
  CONVERT(VARCHAR(10), SUM(DATEDIFF(Minute, TicketRaisedOn, ClosedOn)) / 60)
  + '.' +
  RIGHT('00' + CONVERT(VARCHAR(2), SUM(DATEDIFF(Minute, TicketRaisedOn, ClosedOn)) % 60), 2)
FROM Ticket
GROUP BY ATM

Sql Fiddle:http://sqlfiddle.com/#!3/eca01/1