SELECT lt_location_id location_id, site_name, 2 level
from sites b
where MOBILE_OR_SUBCENTER = 'S'
and inactive_date is null
union
select 'All' location_id , -- is location_id a varchar2 ?
'All locations' ,1 level
from dual
order by level, 1
Select site_name,
sum(NO_OF_DONORS- NO_OF_DEFERRED) no_of_donors,
sum(NO_OF_RESCHED) no_of_resched
from ds_sub_cntr_rebooking a,
sites b
where a.location_id = b.lt_location_id
and coll_date between :start_date and :end_date
and seq_no = :p_seq_no
and location_id = case :p_location_id
when 'All' then location_id
else
:p_location_id
end
group by site_name
order by 1;
or
and location_id = decode(:p_location_id,'All',location_id,:p_location_id)
or
and ((:p_location_id = 'All') or (location_id = :p_location_id))