Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks for checking my idea. I come from a Java background, so I don't have the natural intuition with this. –  demongolem Aug 25 '11 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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