I need to take the count which has a valide date ( any one of date1 or date2) for which i am using this query
I want the o/p to be 4. But i am getting 2. Where am i wrong ???
Instead of 'AND' if i say 'OR' i get 16.
select count(*) from Emp_main a,Emp_sup b
where a.date1 is not null AND
a.date2 is not null
and a.emp_no=b.emp_no
and b.loc='Bangalore'
09:56:53 :ccdw> select count(coalesce(a.date1, a.date2)) from Emp_main a,Emp_sup b
09:56:58 2 where
09:56:58 3 --(a.date1 is not null or
09:56:58 4 --a.date2 is not null)
09:56:58 5 --and
09:56:58 6 a.emp_no=b.emp_no
09:56:58 7 and b.loc='Bangalore';
Bookmarks