mounes13 بتاريخ: 15 يوليو 2019 تقديم بلاغ مشاركة بتاريخ: 15 يوليو 2019 السلام عليكم، اريد ان احول هذا الكند منand exists الىMerge into هل من مساعده ؟ شكرا UPDATE DR_POS pos set MtIntInterPer = (select max(MtFlx) from DR_ECH_OPE ech where ech.DateCurrent = '03/01/2019' AND ech.IdOpe = pos.IdOpe AND ech.IdJmb = pos.IdJmb AND ech.CdTypOpe = pos.CdTypOpe AND ech.CdTypFlx in ('INT', 'IPR') and ech.DtVal=pos.DtProPaiInt) where datecurrent = '03/01/2019' AND CdEtab = 'BPCE' AND exists (select 1 from DR_ECH_OPE ech where ech.DateCurrent = '03/01/2019' AND ech.IdOpe = pos.IdOpe AND ech.IdJmb = pos.IdJmb AND ech.CdTypOpe = pos.CdTypOpe AND ech.CdTypFlx in ('INT', 'IPR') and ech.DtVal=pos.DtProPaiInt ) AND exists (select 1 from DR_ECH_OPE ech where ech.DateCurrent = '03/01/2019' AND ech.IdOpe = pos.IdOpe AND ech.IdJmb = pos.IdJmb AND ech.CdTypOpe = pos.CdTypOpe AND ech.CdTypFlx in ('INT', 'IPR') and DtFinPer=pos.DTARRETE); محاولتي لاكن ليست سليمه: Merge into DR_POS pos using (select max(ech.MtFlx) max_mtflx ,ech.DateCurrent,ech.IdOpe,ech.IdJmb ,ech.CdTypOpe,ech.CdTypFlx,ech.DtVal, ech.DtFinPer from DR_ECH_OPE ech where ech.DateCurrent = '03/01/2019' AND ech.CdTypFlx in ('INT', 'IPR') group by ech.DateCurrent, ech.IdOpe, ech.IdJmb, ech.CdTypOpe, ech.CdTypFlx, ech.DtVal, ech.DtFinPer ) ech on((pos.datecurrent = '03/01/2019' AND pos.CdEtab = 'BPCE' and ech.IdOpe = pos.IdOpe AND ech.IdJmb = pos.IdJmb AND ech.CdTypOpe = pos.CdTypOpe and ech.DtVal=pos.DtProPaiInt ) and (ech.DateCurrent = '03/01/2019' AND ech.IdOpe = pos.IdOpe AND ech.IdJmb = pos.IdJmb AND ech.CdTypOpe = pos.CdTypOpe AND ech.CdTypFlx in ('INT', 'IPR') and ech.DtFinPer=pos.DTARRETE)) when matched then update set MtIntInterPer=max_mtflx ; Merci اقتباس رابط هذا التعليق شارك المزيد من خيارات المشاركة
Recommended Posts
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.