Dec 8, 2011

Try this Query

select * from tmp_table m1where
from
(2-1)=(select count(distinct(m2.age)) tmp_table m2 where m2.age>m1.age) 
 

else
1. Query will return all rows from tmp_table if point 2 is true will return 0 rows.2. (select count(distinct(m2.age)) from tmp_table m2 where m2.age>m1.age)=1There is a cross product between tmp_table m2 and tmp_table m1, so from tmp_table m2 where m2.age>m1.age will return many rows.thus if count of distinct of age from the table tmp_table m2 is 1 then TRUE.Thus if age of all rows in table tmp_table is same... it will return all rows else will retun 0 rowsThus if age of all rows in table tmp_table is same... Query will return all rows else will retun 0 rows

OraApps Search

Custom Search

Search This Blog