Question : oracle forms record group question

SELECT lt_location_id location_id, site_name
from  sites b
where  MOBILE_OR_SUBCENTER = 'S'
and inactive_date is null
order by 1

-----------------------
This is my query.

I want to add 'ALL' for all location id and pull all locations. How tdo I add that in the record group?

--------------
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 = :p_location_id
group by site_name
order by 1;

Here I have to add decode statement to pull for a given location or for ALL. How to do that

Answer : oracle forms record group question

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))                            
Random Solutions  
 
programming4us programming4us