1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| select
[Identifiant du sinistre] = Sin.Sin_Sinistre_id ,
[Année de survenance du sinistre] = Sin.Sin_Annee ,
[Numéro d'ordre sinistre cabinet] = Sin.Sin_SinistreCabinet ,
[Intitulé de la garantie] = SinGa.Singa_Intitule ,
[Intitulé de la convention]=CASE WHEN sin.conv_intitule = 'NEIGE ET MONTAGNE' AND sin.Natu_Intitule = 'Responsabilité civile' THEN 'RC NEIGE ET MONTAGNE' ELSE sin.conv_intitule END,
[Intitulé de la nature]=Sin.Natu_Intitule,
[Dernière évaluation du règlement de la garantie] = SinGa.Singa_EvalReg
into #mandat_eval
from vw_sinistres as Sin inner join si_garanties as SinGa on Sin.sin_sinistre_id = SinGa.singa_sinistre_id
where
(
( Sin.Gest_Intitule != 'Ouvert par erreur')
and ( Sin.Natu_Intitule NOT IN ('Demande de renseignement', 'Hors garantie'))
and ( SinGa.Singa_Intitule = 'Règlement Mandataire')
and ( SinGa.Singa_Sinistre_id NOT IN ( SELECT Singa_sinistre_id FROM si_garanties
GROUP BY Singa_sinistre_id
HAVING COUNT(*) > 2
))
) |