Skip to content
Advertisement

How to evaluate a logical expression in a column in SQL

let’s say I have a database table “ACCOUNTS” where it only has 3 fields:

  1. ACCOUNT_NUMBER (BIGINT)
  2. CREDIT (BIGINT)
  3. DEBIT (BIGINT)

And I simply want to make a query that will show only two columns:

  1. ACCOUNT_NUMBER (BIGINT)
  2. “BALANCED” (A boolean value. True if Credit == Debit, false otherwise)

How do I make such a query?

I tried using the equal operator (=) but it doesn’t accept it

Advertisement

Answer

There’s no Boolean datatype in Oracle’s SQL, so you’ll have to live with its string (or numeric) representation, such as

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement