Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

cara menghitung jumlah waktu dengan tipe data char di 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

Keluaran

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

Demo Langsung



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. ADO.NET untuk menghubungkan Oracle Database di server

  2. Pisahkan File Teks/CSV Besar menjadi Beberapa File di PL SQL

  3. ORA-38868

  4. Fungsi Oracle mengembalikan semua kolom dari tabel

  5. ASP.NET MVC5 - Menjaga Pengguna di Database Oracle