введите описание изображения здесь Выше приведен результат, я просто хочу снизить стоимость мощности. У меня Множественный подзапрос Я хочу меньше кардинальность что мне делать. Я попытался сделать это с помощью предложения with, но он не будет настроен в соответствии с моими требованиями. Запрос выполняется нормально, но мощность и стоимость намного выше, поэтому я хочу разделить мощность
select distinct
C.CLASS_ID,
C.TEACHER_ID,
C.SHIFT_ID,
C.BRANCH_ID,
T.TEACHER_NAME,
ns.nazim_id,
c.class_uid,
(Select count(*) AS total_class from student where upper(class_id)=upper(C.CLASS_ID) and is_active_flg='Y'
and status='STUDYING'
and upper(class_days) like '%'||TO_CHAR(to_date(:P28_DATE),'DY')||'%') as Total_Students,
(select count(*) from student
where class_id=C.CLASS_ID and is_active_flg='Y') as Active_Students,
(select count(*) from student
where class_id=C.CLASS_ID and is_active_flg='N') as InActive_Students,
(Select count(*) as Marked from student_class_attend where upper(class_id)=C.CLASS_ID
and attend_date =:P28_DATE) as Attend_Marked,
(select count(*)
from student
where class_id=C.CLASS_ID and is_active_flg='Y' and gr_number not in (select gr_number from student_class_attend where attend_date=:P28_DATE)
) as Attend_UnMarked,
(select count(*) from student_class_attend
where class_id=C.CLASS_ID and attend_date=:P28_DATE and submit_flg='Y') as attend_submitted,
(select count(*) from student_class_attend
where class_id=C.CLASS_ID and attend_date=:P28_DATE and submit_flg='N') as attend_pending
--qc.unconfirmed
from CLASS C
--join class_time ct on c.class_uid = ct.class_uid
LEFT JOIN student_class_attend SC ON sc.class_id=c.class_id
join nazim_shift ns on decode(:V_GENDER,'BOTH',c.gender,ns.gender) = c.gender
and instr(ns.department_id||':',c.department_id||':')>0
and instr(ns.branch_id||':',c.branch_id||':')>0
and instr(ns.shift_id||':',c.shift_id||':')>0
and ns.nazim_login_id = lower(trim(:APP_USER))
--join nazim_shift_time nst on ns.nazim_shift_uid = nst.nazim_shift_uid
--and nst.class_time=ct.class_time
left join TEACHER T ON C.TEACHER_ID = T.TEACHER_ID and t.active_flg = 'Y'
where c.active_flg = 'Y'
order by c.class_id
;