SQL: Is it possible to SUM() fields of INTERVAL type?
问题 I am trying to sum INTERVAL. E.g. SELECT SUM(TIMESTAMP1 - TIMESTAMP2) FROM DUAL Is it possible to write a query that would work both on Oracle and SQL Server? If so, how? Edit: changed DATE to INTERVAL 回答1: I'm afraid you're going to be out of luck with a solution which works in both Oracle and MSSQL. Date arithmetic is something which is very different on the various flavours of DBMS. Anyway, in Oracle we can use dates in straightforward arithmetic. And we have a function NUMTODSINTERVAL