Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Somme de la différence DateTime en sql (HH.MM)

Faire la sommation avant le formatage

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