Hi All,
My eyes are starting to go funny, below is my code the result without the subselect brings up the correct details so far, what I want to do is join the max(c.itmref_0) to the itmref_0 in the subselect, Hope this makes sense:-
select a.crscode_0,
a.body_0 || ' ' || a.paperlevel_0 || ' ' || a.paper_0 || ' ' || a.crstype_0 as COURSE_NAME,
decode (a.crstype_0, 'BOOSTER', 'ILT', 'CBA', 'ILT', 'CONDENSED', 'ILT', 'EXAM', 'ILT', 'EXTFEED', 'ILT', 'EXTREV', 'ILT', 'FEEDER', 'ILT', 'FULLTIME','ILT',
'HOMESTUDY', 'WBT', 'HSPLUS', 'WBT', 'HSUPGRADE', 'WBT', 'INTENSIVE', 'ILT',
'LINKEXAM', 'ILT', 'MOCK', 'ILT', 'QBREV', 'ILT', 'QUESTDAY', 'ILT', 'REFERRAL', 'ILT', 'RETREV', 'ILT', 'SKILLS', 'ILT', 'STDREV', 'ILT', 'TECH', 'ILT', 'VC', 'WBT', 'WEREV', 'ILT') as DELIVERY_METHOD,
b.genproduct_0, max(c.itmref_0), sub.blah
from bpplive.ybpcrsinst a, bpplive.ybpcimater b, bpplive.sb_transgender c,
(select baspri_0 as blah, itmref_0
from bpplive.itmsales
group by itmref_0, baspri_0) sub
where a.body_0 in ('ACCA', 'CIMA')
and a.crsactive_0 = 2
and a.crscode_0 = 'IP9F16LOI02'
and a.crscode_0 = b.crscode_0
and b.crscode_0 = c.crscode_0
and b.sitting_0 = c.sitting_0
and a.paper_0 = c.paper_0
and b.genproduct_0 = c.genproduct_0
and max(c.itmref_0) = sub.itmref_0
group by a.crscode_0,
a.body_0 || ' ' || a.paperlevel_0 || ' ' || a.paper_0 || ' ' || a.crstype_0,
decode (a.crstype_0, 'BOOSTER', 'ILT', 'CBA', 'ILT', 'CONDENSED', 'ILT',
'EXAM', 'ILT', 'EXTFEED', 'ILT', 'EXTREV', 'ILT', 'FEEDER', 'ILT', 'FULLTIME','ILT', 'HOMESTUDY', 'WBT', 'HSPLUS', 'WBT', 'HSUPGRADE', 'WBT', 'INTENSIVE', 'ILT', 'LINKEXAM', 'ILT', 'MOCK', 'ILT', 'QBREV', 'ILT', 'QUESTDAY', 'ILT', 'REFERRAL', 'ILT', 'RETREV', 'ILT', 'SKILLS', 'ILT', 'STDREV', 'ILT', 'TECH', 'ILT', 'VC', 'WBT', 'WEREV', 'ILT'),
b.genproduct_0, sub.blah
many thanks in advance.
Sam
My eyes are starting to go funny, below is my code the result without the subselect brings up the correct details so far, what I want to do is join the max(c.itmref_0) to the itmref_0 in the subselect, Hope this makes sense:-
select a.crscode_0,
a.body_0 || ' ' || a.paperlevel_0 || ' ' || a.paper_0 || ' ' || a.crstype_0 as COURSE_NAME,
decode (a.crstype_0, 'BOOSTER', 'ILT', 'CBA', 'ILT', 'CONDENSED', 'ILT', 'EXAM', 'ILT', 'EXTFEED', 'ILT', 'EXTREV', 'ILT', 'FEEDER', 'ILT', 'FULLTIME','ILT',
'HOMESTUDY', 'WBT', 'HSPLUS', 'WBT', 'HSUPGRADE', 'WBT', 'INTENSIVE', 'ILT',
'LINKEXAM', 'ILT', 'MOCK', 'ILT', 'QBREV', 'ILT', 'QUESTDAY', 'ILT', 'REFERRAL', 'ILT', 'RETREV', 'ILT', 'SKILLS', 'ILT', 'STDREV', 'ILT', 'TECH', 'ILT', 'VC', 'WBT', 'WEREV', 'ILT') as DELIVERY_METHOD,
b.genproduct_0, max(c.itmref_0), sub.blah
from bpplive.ybpcrsinst a, bpplive.ybpcimater b, bpplive.sb_transgender c,
(select baspri_0 as blah, itmref_0
from bpplive.itmsales
group by itmref_0, baspri_0) sub
where a.body_0 in ('ACCA', 'CIMA')
and a.crsactive_0 = 2
and a.crscode_0 = 'IP9F16LOI02'
and a.crscode_0 = b.crscode_0
and b.crscode_0 = c.crscode_0
and b.sitting_0 = c.sitting_0
and a.paper_0 = c.paper_0
and b.genproduct_0 = c.genproduct_0
and max(c.itmref_0) = sub.itmref_0
group by a.crscode_0,
a.body_0 || ' ' || a.paperlevel_0 || ' ' || a.paper_0 || ' ' || a.crstype_0,
decode (a.crstype_0, 'BOOSTER', 'ILT', 'CBA', 'ILT', 'CONDENSED', 'ILT',
'EXAM', 'ILT', 'EXTFEED', 'ILT', 'EXTREV', 'ILT', 'FEEDER', 'ILT', 'FULLTIME','ILT', 'HOMESTUDY', 'WBT', 'HSPLUS', 'WBT', 'HSUPGRADE', 'WBT', 'INTENSIVE', 'ILT', 'LINKEXAM', 'ILT', 'MOCK', 'ILT', 'QBREV', 'ILT', 'QUESTDAY', 'ILT', 'REFERRAL', 'ILT', 'RETREV', 'ILT', 'SKILLS', 'ILT', 'STDREV', 'ILT', 'TECH', 'ILT', 'VC', 'WBT', 'WEREV', 'ILT'),
b.genproduct_0, sub.blah
many thanks in advance.
Sam