Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Summe der DateTime-Differenz in SQL (HH.MM)

Summieren Sie vor der Formatierung

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