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

Oracle SQL membandingkan catatan dalam tabel

Satu ide dasar adalah menggunakan join :

select t0.item_id, t0.code as code_0, t1.code as code_1
from t t0 join
     t t1
     on t0.item_id = t1.item_id and
        t0.item_revision = 0 and
        t1.item_revision = 1
where t0.code <> t1.code;

Namun, jika code nilainya NULL (atau string kosong), Anda harus lebih berhati-hati:

where t0.code <> t1.code or (t0.code is null and t1.code is not null) or
      (t0.code is not null and t1.code is null) 


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. PILIH yang terbaru di Oracle SQL Query

  2. Kesalahan ORA-12638 di Oracle Database 11g

  3. Bagaimana saya bisa mendapatkan semua informasi tentang tabel di Oracle?

  4. Permintaan untuk menemukan harga tertimbang rata-rata

  5. Oracle SQL - Bagaimana cara mendapatkan jumlah yang berbeda untuk setiap kolom secara dinamis?