Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Somma della differenza DateTime in sql (HH.MM)

Fai la somma prima della formattazione

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