This document contains an SQL query that selects and aggregates data from various tables to generate a report on items, schedules, catalogs, and other related data. The query selects item details, schedule details like dates and locations, related catalogs and subjects, instructor details, and other associated data. It uses joins across multiple tables, aggregation functions like COUNT and LISTAGG, and other SQL features to consolidate the information for reporting purposes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
122 views
Base Data Set
This document contains an SQL query that selects and aggregates data from various tables to generate a report on items, schedules, catalogs, and other related data. The query selects item details, schedule details like dates and locations, related catalogs and subjects, instructor details, and other associated data. It uses joins across multiple tables, aggregation functions like COUNT and LISTAGG, and other SQL features to consolidate the information for reporting purposes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5
select distinct c.
cpnt_id AS "Item ID",
c.cpnt_title, DECODE(c.notactive,'Y','N','N','Y') AS "Item Status", c.cpnt_typ_id as "Item Type", nvl(mst.show_in_catalog,'N') AS "Content is Published (Y/N)", (select LISTAGG(coll_inner.label_value,'; ') WITHIN GROUP (ORDER BY coll_inner.label_value) from (select a.cpnt_typ_id, a.cpnt_id, a.rev_dte, loc.label_value from pa_cpnt_subj a, pv_subj_relation b, pa_subj c, pa_i18n_localized_label loc where b.subj_id_child = a.subj_id and b.subj_id_parent in ('REG002','REG003','REG004','REG005','REG006','REG007') and c.subj_id = b.subj_id_parent and loc.label_id = c.subj_desc and loc.locale_id = 'English' union select a.cpnt_typ_id, a.cpnt_id, a.rev_dte, nvl(loc.label_value,'-') from pa_cpnt_subj a, pv_subj_relation b, pa_subj c, pa_i18n_localized_label loc where b.subj_id_child = a.subj_id and a.subj_id like 'COL%' and b.subj_id_parent like 'COL%' and b.subj_id_parent <> 'COL0011' and c.subj_id = b.subj_id_parent and loc.label_id = c.subj_desc and loc.locale_id = 'English' union select a.cpnt_typ_id, a.cpnt_id, a.rev_dte, loc.label_value from pa_cpnt_subj a, pv_subj_relation b, pa_subj c, pa_i18n_localized_label loc where a.subj_id = 'COL0011' and b.subj_id_parent = a.subj_id and b.subj_id_child = c.subj_id and b.subj_id_child in (select x.subj_id from pa_cpnt_subj x where x.cpnt_typ_id = a.cpnt_typ_id and x.cpnt_id = a.cpnt_id and x.rev_dte = a.rev_dte and x.subj_id like 'CAP%' ) and loc.label_id = c.subj_desc and loc.locale_id = 'English' union select a.cpnt_typ_id, a.cpnt_id, a.rev_dte, nvl(loc.label_value,'-') from pa_cpnt_subj a, pv_subj_relation b, pa_subj c, pa_i18n_localized_label loc where b.subj_id_child = a.subj_id and a.subj_id in ('CAP052','CAP053','CAP054','CAP055','CAP056') and b.subj_id_parent in ('CAP052','CAP053','CAP054','CAP055','CAP056') and c.subj_id = b.subj_id_parent and loc.label_id = c.subj_desc and loc.locale_id = 'English' ) coll_inner where coll_inner.cpnt_typ_id = c.cpnt_typ_id and coll_inner.cpnt_id = c.cpnt_id and coll_inner.rev_dte = c.rev_dte ) as "College/Academy", (select LISTAGG(cat_inner.catalog_desc,'; ') WITHIN GROUP (ORDER BY cat_inner.catalog_desc) as cat_List from (select cati.cpnt_typ_id, cati.cpnt_id, cati.rev_dte, cati.catalog_id, cat.catalog_desc from pa_catalog_item cati, pa_catalog cat where cati.catalog_id = cat.catalog_id) cat_inner where cat_inner.cpnt_typ_id = c.cpnt_typ_id and cat_inner.cpnt_id = c.cpnt_id and cat_inner.rev_dte = c.rev_dte ) as "Catalog", (select LISTAGG(coll_inner.label_value,'; ') WITHIN GROUP (ORDER BY coll_inner.label_value) from (select csub.cpnt_typ_id, csub.cpnt_id, csub.rev_dte, loc.label_value from pa_cpnt_subj csub, pa_subj csubd, pa_i18n_localized_label loc where csub.subj_id like 'COMP%' and csub.subj_id = csubd.subj_id and loc.label_id = csubd.subj_desc and loc.locale_id = 'English' ) coll_inner where coll_inner.cpnt_typ_id = c.cpnt_typ_id and coll_inner.cpnt_id = c.cpnt_id and coll_inner.rev_dte = c.rev_dte ) as "Supported Competency(ies)", (select LISTAGG(coll_inner.label_value,'; ') WITHIN GROUP (ORDER BY coll_inner.label_value) from (select csub.cpnt_typ_id, csub.cpnt_id, csub.rev_dte, loc.label_value from pa_cpnt_subj csub, pa_subj csubd, pa_i18n_localized_label loc where csub.subj_id like 'CAP%' and not exists (select x.subj_id from pa_cpnt_subj x where x.cpnt_typ_id = csub.cpnt_typ_id and x.cpnt_id = csub.cpnt_id and x.rev_dte = csub.rev_dte and x.subj_id = 'COL0011') and csub.subj_id = csubd.subj_id and loc.label_id = csubd.subj_desc and loc.locale_id = 'English' ) coll_inner where coll_inner.cpnt_typ_id = c.cpnt_typ_id and coll_inner.cpnt_id = c.cpnt_id and coll_inner.rev_dte = c.rev_dte ) as "Supported Capability(ies)", s.schd_id AS "Offering ID", decode(s.notactive,'Y','N','N','Y') AS "Offering Availability (Y/N)", ssmin.start_dte AS "Offering Start Date",--seg_startdate, --ssmin.start_tme AS ss_seg_starttime, ssmax.end_dte AS "Offering End Date", --seg_enddate, --ssmax.end_tme AS ss_seg_endtime, --ssmin.start_dte startdate, --ssmin.start_tme AS starttime, --ssmax.end_dte enddate, --ssmax.end_tme AS endtime, ssmin.timezone_id TIMEZONE, --ssmin.display_in_schd_tz displaytimezone, f.city AS "City Of Facility", ct.country_desc AS "Country Of Facility", msts.cancel_policy_id AS "Cancellation Policy", cf.formula AS "Activity Price", nvl(s.max_enrl,0) AS "Max Capacity of the Offering", nvl(s.min_enrl,0) AS "Min Capacity of the Offering", (select nvl(count(*),0) from pa_enroll_seat es where es.schd_id = s.schd_id and es.enrl_stat_id = 'ENROLL') AS "Number of Enrolled Users", (select nvl(count(*),0) from pa_enroll_seat es where es.schd_id = s.schd_id and es.enrl_stat_id = 'PENDING') AS "Number of Pending Users", (select nvl(count(*),0) from pa_enroll_seat es where es.schd_id = s.schd_id and es.enrl_stat_id = 'WITHDRAWN') AS "Number of Withdrawn Users", (select nvl(count(*),0) from pa_enroll_seat es where es.schd_id = s.schd_id and es.enrl_stat_id = 'CANCELLED') AS "Number of Cancelled Users", (select nvl(count(*),0) from pa_enroll_seat es where es.schd_id = s.schd_id and es.enrl_stat_id = 'NO-SHOW') AS "Number of No Show Users", (select nvl(count(*),0) from pa_enroll_seat es where es.schd_id = s.schd_id and es.enrl_stat_id = 'WAITLIST') AS "Number of Waitlisted Users", (select distinct instn.fname || ' ' || instn.lname as inst_list from pa_ssg_inst inst, pa_student instn where inst.schd_id = s.schd_id and inst.inst_id = instn.stud_id and inst.ssg_seg_num = 1 and inst.primary = 'Y') AS "Instructor Name",/* (select listagg(sn.name, '; ') within group (order by sn.seq_num) from pa_sch_notify sn where sn.schd_id = s.schd_id) AS "Vendor Name",*/ Catalog.cpnt_len as "Length", -- Added for CIP 261 pa_cpnt.credit_hrs AS "Credit Hours" -- Added for CIP 261 FROM pv_course c, pa_sched s, pa_facility f, pa_country ct, pa_cpnt_formula cf, pa_master_inv mst, pa_master_inv_sched msts, pa_cpnt_subj college, pa_catalog_item catalog, pa_ssg_inst instructor, (select ssg.schd_id, ssg.start_dte, ssg.start_tme, ps.timezone_id, ps.display_in_schd_tz from pa_sch_seg ssg, pa_sched ps where ssg.schd_id=ps.schd_id AND ssg.start_dte = (select min(ssg1.start_dte) from pa_sch_seg ssg1 where ssg1.schd_id = ssg.schd_id)) ssmin, (select ssg.schd_id, ssg.end_dte, ssg.end_tme, ps.timezone_id, ps.display_in_schd_tz from pa_sch_seg ssg, pa_sched ps where ssg.schd_id=ps.schd_id AND ssg.end_dte = (select max(ssg1.end_dte) from pa_sch_seg ssg1 where ssg1.schd_id = ssg.schd_id)) ssmax, pa_cpnt WHERE c.cpnt_typ_id = s.cpnt_typ_id(+) AND c.cpnt_id = s.act_cpnt_id(+) AND c.rev_dte = s.rev_dte(+) AND s.schd_id = ssmin.schd_id(+) AND s.schd_id = ssmax.schd_id(+) AND s.facility_id = f.facility_id (+) AND f.cntry = ct.country_id (+) AND c.cpnt_typ_id = cf.cpnt_typ_id(+) AND c.cpnt_id = cf.cpnt_id(+) AND c.rev_dte = cf.rev_dte(+) AND cf.fin_var_id(+) = 'ItemDefaultPublishedPrice' AND c.cpnt_typ_id = mst.cpnt_typ_id(+) AND c.cpnt_id = mst.cpnt_id(+) AND c.rev_dte = mst.rev_dte(+) AND s.cpnt_typ_id = msts.cpnt_typ_id(+) AND s.act_cpnt_id = msts.cpnt_id(+) AND s.rev_dte = msts.rev_dte(+) AND s.schd_id = msts.schd_id(+) AND c.cpnt_typ_id = college.cpnt_typ_id(+) AND c.cpnt_id = college.cpnt_id(+) AND c.rev_dte = college.rev_dte(+) AND c.cpnt_typ_id = catalog.cpnt_typ_id(+) AND c.cpnt_id = catalog.cpnt_id(+) AND c.rev_dte = catalog.rev_dte(+) AND s.schd_id = instructor.schd_id(+) AND c.cpnt_id = pa_cpnt.cpnt_id(+) AND c.notactive IN ('n','N') --AND c.cpnt_id in ('1360','1768','40895','41266') -- and (c.cpnt_id in ('10005','00020120','00034360','10000007') or -- and s.schd_id in ('78614','11237') /** AND (c.cpnt_typ_id,c.cpnt_id,c.rev_dte) in [ItemSearch] AND college.subj_id in [SubjectAreaSearch] AND catalog.catalog_id in [CatalogSearch] AND s.schd_id in [ScheduleSearch] AND trunc(ssmin.start_dte) >= [OfferingStartDateFrom] AND trunc(ssmin.start_dte) <= [OfferingStartDateTo] AND trunc(ssmax.end_dte) >= [OfferingEndDateFrom] AND trunc(ssmax.end_dte) <= [OfferingEndDateTo] AND f.city = [CitySearch] AND f.cntry in [CountrySearch] AND instructor.inst_id in [InstructorSearch] AND [security:pv_course c] */