sql >> Database teknologi >  >> RDS >> Oracle

hvordan man beregner sumtiden med datatypen char i oracle

WITH x AS ( SELECT t1.time_rent AS t1, t2.time_rent AS t2, ((SUBSTR(t1.time_rent,1,2) * 3600) + (SUBSTR(t1.time_rent,4,2) * 60) + (SUBSTR(t2.time_rent,1,2) * 3600) + (SUBSTR(t2.time_rent,4,2) * 60)) AS t FROM table1 t1 INNER JOIN Table2 t2 ON t1.name=t2.name ), y AS( SELECT t1, t2, numtodsinterval(t,'second') AS t FROM x ) SELECT T1, T2, (EXTRACT(day FROM t) * 24 + EXTRACT(hour FROM t) ||':' || EXTRACT(minute FROM t) ||':' || EXTRACT(second FROM t)) AS duration FROM y

Output

T1      T2      DURATION
07:30   18:30   26:0:0
 

Live-demo



  1. PHP/MySQL:Henter de sidste *fulde* ugers poster

  2. mysql:whoami?

  3. Levenshtein:MySQL + PHP

  4. PostgreSQL:Hvordan undslippe '?