2

I have the following query which works for me:

select count(*)
from (
   select UNIQUE col1, col2, col3
   from my_table
   where cond1 = 'A'
   and cond2 = 'B'
   and cond3 = 'C'
)

Is it possible to write this without the nested query?

1 Answer 1

3

Not that I recommend it, but:

select count(distinct ora_hash(col1)||'|'||ora_hash(col2)||'|'||ora_hash(col3))
from my_table
where cond1 = 'A'
and cond2 = 'B'
and cond3 = 'C'

A nested query seems like "the right answer" to me.

1
  • Thanks for checking my idea. I come from a Java background, so I don't have the natural intuition with this.
    – demongolem
    Commented Aug 25, 2011 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.