select total, male, female, hispanic, white, american_indian, black, mexican, less18, age18_20, age21_23, age24_26, age27_29, age30_39, age40_49, age50_59, age60, noage, ageTwo from ( select 1 as dummy, count ( distinct person_id ) as total from bookings a, placements b where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 )) a, ( select 1 as dummy, count ( distinct c.person_id ) as male from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and c.sex_sex_code = 'M') b, ( select 1 as dummy, count ( distinct c.person_id ) as female from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and c.sex_sex_code = 'F') c, ( select 1 as dummy, count ( distinct a.person_id ) as hispanic from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and (c.race_race_code = 'H' or c.race_race_code = 'M') ) e, ( select 1 as dummy, count ( distinct a.person_id ) as white from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and c.race_race_code = 'W') f, ( select 1 as dummy, count ( distinct a.person_id ) as american_indian from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and c.race_race_code = 'I') g, ( select 1 as dummy, count ( distinct a.person_id ) as black from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and c.race_race_code = 'B') h, ( select 1 as dummy, count ( distinct a.person_id ) as mexican from bookings a, placements b, people c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.person_id and c.race_race_code = 'M') k, ( select 1 as dummy, count ( distinct a.person_id ) as less18 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob )/12.0 < 18.0 ) aa, ( select 1 as dummy, count ( distinct a.person_id ) as age18_20 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 > 18.0 and months_between(:inputDate, c.dob)/12.0 <= 20.0) ab, ( select 1 as dummy, count ( distinct a.person_id ) as age21_23 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 > 20.0 and months_between(:inputDate, c.dob)/12.0 <= 23.0) ac, ( select 1 as dummy, count ( distinct a.person_id ) as age24_26 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 > 23.0 and months_between(:inputDate, c.dob)/12.0 <= 26.0) ad, ( select 1 as dummy, count ( distinct a.person_id ) as age27_29 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 >26.0 and months_between(:inputDate, c.dob)/12.0 <= 29.0) ae, ( select 1 as dummy, count ( distinct a.person_id ) as age30_39 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 > 29 and months_between(:inputDate, c.dob)/12.0 <= 39.0) af, ( select 1 as dummy, count ( distinct a.person_id ) as age40_49 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 > 39 and months_between(:inputDate, c.dob)/12.0 <= 49.0) ag, ( select 1 as dummy, count ( distinct a.person_id ) as age50_59 from bookings a, placements b, ( select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 > 49.0 and months_between(:inputDate, c.dob)/12.0 <= 59.0) ah, ( select 1 as dummy, count ( distinct a.person_id ) as age60 from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and months_between(:inputDate, c.dob)/12.0 >= 59.0) ak, ( select 1 as dummy, count ( distinct a.person_id ) as noAge from bookings a, placements b, (select per_person_id, min( dob ) as dob from master_names group by per_person_id) c where :inputDate between a.arrival_date and nvl( release_date, sysdate ) and :inputDate between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and a.arrival_date > '1-Jan-2000' and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.person_id = c.per_person_id and c.dob is null) am, ( select 1 as dummy, count ( distinct a.per_person_id ) as ageTwo from (select c.per_person_id, count (distinct c.dob ) as numDOB from bookings a, placements b, master_names c where '01-Jan-2005' between a.arrival_date and nvl( release_date, sysdate ) and '01-Jan-2005' between b.start_date and nvl( b.end_date, sysdate ) and a.booking_number = b.booking_number and b.cell_block_id not in ( 9030, 9347, 9306, 9190, 9327, 9020, 9408, 9040, 9130, 9388, 9150, 9280 ) and a.arrival_date > '1-Jan-2000' and a.person_id = c.per_person_id group by c.per_person_id) a where a.numDOB > 1 ) an where a.dummy = b.dummy and b.dummy = c.dummy and c.dummy = e.dummy and e.dummy = f.dummy and f.dummy = g.dummy and g.dummy = h.dummy and h.dummy = k.dummy and k.dummy = aa.dummy and aa.dummy = ab.dummy and ab.dummy = ac.dummy and ac.dummy = ad.dummy and ad.dummy = ae.dummy and ae.dummy = af.dummy and af.dummy = ag.dummy and ag.dummy = ah.dummy and ah.dummy = ak.dummy and ak.dummy = am.dummy and am.dummy = an.dummy /