Qry_DerivePonderations INSERT INTO T_DerivePonderation ( ClasseActifs, DateValo, PoidsDerive, ElementPonderation, ElementIndice, Indice, IndiceCompose, Ponderation ) SELECT IdClasse_actifs, DateValo, PoidsDerive, IdElementPonderation, IdElementIndice, Indice, IdIndiceCompose, IdPonderation FROM Qry_UNION_DerivePonderations; Qry_UNION_DerivePonderations SELECT * FROM Qry_DerivePonderations_Part1 UNION SELECT * FROM Qry_DerivePonderations_Part2; Qry_DerivePonderations_Part1 SELECT DISTINCT T_ClasseActifs.IdClasse_actifs, T_Perf_Indice_Mensuelle_TMP.DateValo, IIf([Poids]=1 Or T_Perf_Indice_Mensuelle_TMP.DateValo=T_Pondération.DateApplication Or [DateValo]=[DerniereDateMois],[Poids],IIf(Format([DateValo],"yyyy/mm")=Format(T_Pondération.DateApplication,"yyyy/mm"),[Poids]*(T_Perf_Indice_Mensuelle_TMP.Valo/T_All_ValRef_TMP.Valo),[Poids]*(1+[PerfMensuelle]))) AS PoidsDerive, T_ElementPonderation.IdElementPonderation, T_ElementIndice.IdElementIndice, T_ElementIndice.Indice, T_IndiceCompose.IdIndiceCompose, T_Pondération.IdPonderation FROM (T_ListeIndices INNER JOIN T_ClasseActifs ON T_ListeIndices.IdListeIndices = T_ClasseActifs.liste_indices_perf) INNER JOIN (((T_IndiceCompose LEFT JOIN T_IndiceCompose AS T_IndiceCompose_1 ON T_IndiceCompose.Suivant = T_IndiceCompose_1.IdIndiceCompose) INNER JOIN ((T_ElementIndice INNER JOIN (T_Perf_Indice_Mensuelle_TMP INNER JOIN T_All_ValRef_TMP ON T_Perf_Indice_Mensuelle_TMP.Indice = T_All_ValRef_TMP.Indice) ON T_ElementIndice.Indice = T_Perf_Indice_Mensuelle_TMP.Indice) INNER JOIN T_ElementPonderation ON T_ElementIndice.IdElementIndice = T_ElementPonderation.ElementIndice) ON T_IndiceCompose.IdIndiceCompose = T_ElementIndice.IndiceCompo) INNER JOIN T_Pondération ON (T_IndiceCompose.IdIndiceCompose = T_Pondération.IndiceCompose) AND (T_Pondération.IdPonderation = T_ElementPonderation.Ponderation)) ON T_ListeIndices.IdListeIndices = T_IndiceCompose.Liste WHERE (((T_Perf_Indice_Mensuelle_TMP.DateValo)>=T_Pondération.DateApplication And (T_Perf_Indice_Mensuelle_TMP.DateValo)>=T_IndiceCompose.Date_Implementation And (T_Perf_Indice_Mensuelle_TMP.DateValo)=[date_début])); Qry_DerivePonderations_Part2 SELECT DISTINCT T_ClasseActifs.IdClasse_actifs, T_Perf_Indice_Mensuelle_TMP.DateValo, IIf([Poids]=1 Or T_Perf_Indice_Mensuelle_TMP.DateValo=T_Pondération.DateApplication Or [DateValo]=[DerniereDateMois],[Poids],IIf(Format([DateValo],"yyyy/mm")=Format(T_Pondération.DateApplication,"yyyy/mm"),[Poids]*(T_Perf_Indice_Mensuelle_TMP.Valo/T_All_ValRef_TMP.Valo),[Poids]*(1+[PerfMensuelle]))) AS PoidsDerive, T_ElementPonderation.IdElementPonderation, T_ElementIndice.IdElementIndice, T_ElementIndice.Indice, T_IndiceCompose.IdIndiceCompose, T_Pondération.IdPonderation FROM (T_ListeIndices INNER JOIN T_ClasseActifs ON T_ListeIndices.IdListeIndices = T_ClasseActifs.liste_indices_perf) INNER JOIN (((T_IndiceCompose LEFT JOIN T_IndiceCompose AS T_IndiceCompose_1 ON T_IndiceCompose.Suivant = T_IndiceCompose_1.IdIndiceCompose) INNER JOIN ((T_ElementIndice INNER JOIN (T_Perf_Indice_Mensuelle_TMP INNER JOIN T_All_ValRef_TMP ON T_Perf_Indice_Mensuelle_TMP.Indice = T_All_ValRef_TMP.Indice) ON T_ElementIndice.Indice = T_Perf_Indice_Mensuelle_TMP.Indice) INNER JOIN T_ElementPonderation ON T_ElementIndice.IdElementIndice = T_ElementPonderation.ElementIndice) ON T_IndiceCompose.IdIndiceCompose = T_ElementIndice.IndiceCompo) INNER JOIN T_Pondération ON (T_IndiceCompose.IdIndiceCompose = T_Pondération.IndiceCompose) AND (T_Pondération.IdPonderation = T_ElementPonderation.Ponderation)) ON T_ListeIndices.IdListeIndices = T_IndiceCompose.Liste WHERE (((T_Perf_Indice_Mensuelle_TMP.DateValo)>=T_Pondération.DateApplication And (T_Perf_Indice_Mensuelle_TMP.DateValo)>=T_IndiceCompose.Date_Implementation And (T_Perf_Indice_Mensuelle_TMP.DateValo)>=[date_début]) And ((T_IndiceCompose_1.Date_Implementation) Is Null)) AND ((T_IndiceCompose_1.Date_Implementation) Is Null) and [T_Pondération].Idponderation = T_All_ValRef_TMP.Idponderation; Qry_Perf_Indice_Mensuelle SELECT Qry_Indice_UPG.Indice, Qry_Indice_UPG.DateValo, Qry_Val_Indice_1er_mois.PremiereDateMois, Qry_Val_Indice_1er_mois.DerniereDateMois, [Qry_Indice_UPG].[Valo], [Qry_Indice_UPG].[Valo]/[ValRef]-1 AS PerfMensuelle, [T_HistoIndice].[Valo]/[ValRef]-1 AS PerfMensuelleVeille FROM (Qry_Indice_UPG INNER JOIN Qry_Val_Indice_1er_mois ON (Qry_Indice_UPG.Indice = Qry_Val_Indice_1er_mois.Indice) AND (Qry_Indice_UPG.Mois = Qry_Val_Indice_1er_mois.Mois)) LEFT JOIN T_HistoIndice ON Qry_Indice_UPG.HistoPrec = T_HistoIndice.IdHistoIndice; Qry_All_ValRef SELECT Qry_Perf_Indice_Mensuelle.Indice, Qry_Perf_Indice_Mensuelle.Valo, [T_Pondération].[DateApplication], [T_Pondération].Idponderation FROM (T_ListeIndices INNER JOIN T_ClasseActifs ON T_ListeIndices.IdListeIndices = T_ClasseActifs.liste_indices_perf) INNER JOIN (((T_IndiceCompose LEFT JOIN T_IndiceCompose AS T_IndiceCompose_1 ON T_IndiceCompose.Suivant = T_IndiceCompose_1.IdIndiceCompose) INNER JOIN ((T_ElementIndice INNER JOIN (Qry_Perf_Indice_Mensuelle INNER JOIN Qry_dateDepart_Indice ON Qry_dateDepart_Indice.Indice = Qry_Perf_Indice_Mensuelle.Indice) ON T_ElementIndice.Indice = Qry_Perf_Indice_Mensuelle.Indice) INNER JOIN T_ElementPonderation ON T_ElementIndice.IdElementIndice = T_ElementPonderation.ElementIndice) ON T_IndiceCompose.IdIndiceCompose = T_ElementIndice.IndiceCompo) INNER JOIN T_Pondération ON (T_IndiceCompose.IdIndiceCompose = T_Pondération.IndiceCompose) AND (T_Pondération.IdPonderation = T_ElementPonderation.Ponderation)) ON T_ListeIndices.IdListeIndices = T_IndiceCompose.Liste WHERE (((Qry_Perf_Indice_Mensuelle.DateValo)>=[T_Pondération].[DateApplication] And (Qry_Perf_Indice_Mensuelle.DateValo)>=[T_IndiceCompose].[Date_Implementation] And (Qry_Perf_Indice_Mensuelle.DateValo)<[T_IndiceCompose_1].[Date_Implementation])) OR (((Qry_Perf_Indice_Mensuelle.DateValo)>=[T_Pondération].[DateApplication] And (Qry_Perf_Indice_Mensuelle.DateValo)>=[T_IndiceCompose].[Date_Implementation]) AND ((T_IndiceCompose_1.Date_Implementation) Is Null)) AND (Qry_Perf_Indice_Mensuelle.DateValo = [T_Pondération].[DateApplication] OR Qry_Perf_Indice_Mensuelle.DateValo = Qry_dateDepart_Indice.DateDepart); Qry_Indice_UPG SELECT T_HistoIndice.*, Year([DateValo]) AS Annee, DateSerial(Year([T_HistoIndice].[DateValo]),Month([T_HistoIndice].[DateValo]),1) AS Mois, DateSerial(Year([T_HistoIndice].[DateValo]),1+3*(Int((Month([T_HistoIndice].[DateValo])/3))-0^(Month([T_HistoIndice].[DateValo]) Mod 3)),1) AS [Trim] FROM T_HistoIndice; Qry_Val_Indice_1er_mois SELECT T_HistoIndice.Indice, DateSerial(Year([T_HistoIndice].[DateValo]),Month([T_HistoIndice].[DateValo]),1) AS Mois, Min(T_HistoIndice.DateValo) AS PremiereDateMois, Max(T_HistoIndice.DateValo) AS DerniereDateMois, First(T_HistoIndice.Valo) AS PremiereValoMois, Min(T_HistoIndice_1.DateValo) AS DatePrecedente, First(T_HistoIndice_1.Valo) AS ValoPrecedente, IIf([DatePrecedente]=[PremiereDateMois] Or IsNull([DatePrecedente]),[PremiereValoMois],[ValoPrecedente]) AS ValRef FROM T_HistoIndice LEFT JOIN T_HistoIndice AS T_HistoIndice_1 ON T_HistoIndice.HistoPrec = T_HistoIndice_1.IdHistoIndice GROUP BY T_HistoIndice.Indice, DateSerial(Year([T_HistoIndice].[DateValo]),Month([T_HistoIndice].[DateValo]),1); Qry_dateDepart_Indice SELECT Qry_Indice_UPG.Indice, min(Qry_Indice_UPG.DateValo) AS DateDepart FROM (Qry_Indice_UPG INNER JOIN Qry_Val_Indice_1er_mois ON (Qry_Indice_UPG.Mois = Qry_Val_Indice_1er_mois.Mois) AND (Qry_Indice_UPG.Indice = Qry_Val_Indice_1er_mois.Indice)) LEFT JOIN T_HistoIndice ON Qry_Indice_UPG.HistoPrec = T_HistoIndice.IdHistoIndice GROUP BY Qry_Indice_UPG.Indice;