I'm using Oracle and I want to turn the result from a select count into a "binary" 0/1 value ... 0 = 0 ... non-zero = 1. From what I read online, in MS SQL, you can cast it to a "bit" but Oracle doesn't appear to support that.
Here's my simple example query (the real query is much more complex). I want MATCH_EXISTS to always be 0 or 1. Is this possible?
select count(*) as MATCH_EXISTS
from MY_TABLE
where MY_COLUMN is not null;
This should be fastest... get at most one row.
SELECT COUNT(*) AS MATCH_EXISTS
FROM MY_TABLE
WHERE MY_COLUMN IS NOT NULL
AND rownum <= 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With