Erreur SQL !
SELECT RIGHT(LotFSE.NoLot,3) as NoLot, LotFSE.NoLot as NoLotComplet, CASE WHEN crl.NoFacture=0 THEN crl.AncNoFacture ELSE crl.NoFacture END as NoFacture, beneficiaire.noss, beneficiaire.cless, beneficiaire.nom + ' ' + beneficiaire.prenom as nombenef, beneficiaire.datenaissance, crl.MontantTotal, LotFSE.Regime, LotFSE.NomOrganisme,organismes.libelle_regime,organismes.adresse1,organismes.adresse2,organismes.codepostal,organismes.commune,crl.DateEnvoi, crl.IdPS, dbo.formatdate(LotFSE.DateFormatage,'dd/mm/yyyy à hh:mm:ss') as DateFormatage, regimes.intitule_regime, LotFSE.DestLot,factures.partamoreel, factures.partamcreel, FichierTeletrans.id_teletrans, factures.renouvel, LotFSE.ModeSecurisation,factures.ATDate,crl.recycle FROM (((assure AS beneficiaire RIGHT JOIN (((LotFSE left join organismes on lotfse.index_org=organismes.index_org) RIGHT JOIN crl ON LotFSE.NoLot = crl.NoLot) INNER JOIN factures ON CASE WHEN crl.NoFacture=0 THEN crl.AncNoFacture ELSE crl.NoFacture END = factures.NoFacture) ON beneficiaire.index_assure = factures.index_assure) LEFT JOIN assure ON (beneficiaire.noss = assure.noss and assure.lien='ASSURE')) LEFT JOIN regimes ON LotFSE.Regime = regimes.index_regime) LEFT JOIN FichierTeletrans ON LotFSE.IndexNomFichier = FichierTeletrans.id_teletrans WHERE (assure.lien='ASSURE' or assure.index_assure is null) and CASE WHEN crl.NoFacture=0 THEN crl.AncNoFacture ELSE crl.NoFacture END IN () ORDER BY LotFSE.Regime,substring(DestLot,6,8),LotFSE.NoLot,CASE WHEN crl.NoFacture=0 THEN crl.AncNoFacture ELSE crl.NoFacture END