1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
update rdt_fs_histo_mca mca
set (D_DATE_RATING_MO)=
--je suis obligé de sélectionné les 4 champs afin que le group by
--soit correct et pour faire une clause where tout en bas..
(
select
sel.code_sp,
sel.code_mo,
max(sel.date_mo) as max_date_mo,
sel.d_rating_date as date_sp
from (
select distinct
max(mo.d_rating_date),
mo.d_rating_date as date_mo,
mo.c_current_rating,
mo.c_rating_agency_issuer as code_mo,
sp.d_rating_date,
sp.c_rating_agency_issuer as code_sp,
sp.c_current_rating as rating_sp
from
rdt_fs_histo_mo mo,
rdt_fs_histo_sp sp,
r_fslom fs
where
mo.c_rating_agency_issuer=fs.c_rating_agency_mo
and sp.c_rating_agency_issuer=fs.c_rating_agency_sp
and mo.d_rating_date<=sp.d_rating_date
and mo.c_rating_agency_issuer=0000172200
group by
mo.c_current_rating,
mo.c_rating_agency_issuer,
sp.d_rating_date,
mo.d_rating_date,
sp.c_rating_agency_issuer,
sp.c_current_rating
) sel
where sel.d_rating_date>= sel.date_mo
group by
sel.d_rating_date,
sel.code_sp,
sel.code_mo
) selmax
where mca.c_rating_agency_sp=selmax.code_sp
and mca.d_date_rating_sp=selmax.date_sp |
Partager