Bonjour,

Voici ma requête

Code SQL : Sélectionner tout - Visualiser dans une fenêtre à part
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
SELECT DISTINCT totemadm_TBIMMOPL.IMM_CODE,
totemadm_TBIMMOPL.D_DEBUT,
totemadm_TBIMMOFI.LIBELLE01,
totemadm_TBIMMOFI.LIBELLE02,
totemadm_TBIMMOFI.LIBELLE03,
totemadm_TBIMMOFI.LIBELLE04,
totemadm_TBIMMOFI.A01_IMMO,
totemadm_TBIMMOCP.GEN_CODE AS [Code d'acquisition],
totemadm_TBIMMOPL.BASE_AMORT,
PseudoIMMOCP.GEN_CODE AS [Compte d'amort],
IIf([totemadm_TBIMMOPL].[TYPE_AMORT]="LIN",[totemadm_TBIMMOPL].[TAUX_01],IIf([totemadm_TBIMMOPL].[TYPE_AMORT]="DEG",[totemadm_TBIMMOPL].[TAUX_02],[totemadm_TBIMMOPL].[TYPE_AMORT])) AS Taux,
totemadm_TBIMMOFI.MT_HT AS [Montant HT],
IIf([totemadm_TBIMMOPL].[NUM_PLAN]="01","COMPTA",IIf([totemadm_TBIMMOPL].[NUM_PLAN]="02","FISCAL")) AS NUM_PLAN,
totemadm_TBIMMOFI.MT_HT, IIf([totemadm_TBIMMOAM].[NUM_PLAN]="01",([totemadm_TBIMMOAM].[VCN_FIN_PER])) AS VNC,
totemadm_TBIMMOPL.TYPE_AMORT,
totemadm_TBIMMOPL.ID_REGLE,
totemadm_TBIMMOFI.TIE_NOMF
FROM totemadm_TBIMMOAM, totemadm_TBIMMOPL, totemadm_TBIMMOFI, totemadm_TBIMMOCP INNER JOIN totemadm_TBIMMOCP AS PseudoIMMOCP ON totemadm_TBIMMOCP.ID_IMMO = PseudoIMMOCP.ID_IMMO
WHERE totemadm_TBIMMOPL.IMM_CODE="215430004201000" 
AND totemadm_TBIMMOCP.ID_IMMO=totemadm_TBIMMOAM.ID_IMMO
AND totemadm_TBIMMOAM.ID_IMMO=totemadm_TBIMMOPL.ID_IMMO
AND totemadm_TBIMMOPL.ID_IMMO=totemadm_TBIMMOFI.ID_IMMO
AND totemadm_TBIMMOCP.NUM_LIGNECPT="01"
AND PseudoIMMOCP.NUM_LIGNECPT="02"
AND totemadm_TBIMMOAM.DATE_AU = #12/31/2009#;

Avec cet IMM_CODE là je dois obtenir 2 lignes, cependant il me faut une autre condition mais je ne sais pas comment l'écrire :

Si TBIMMOPL.TYPE_AMORT = "LIN" pour TBIMMOPL.NUM_PLAN = "01" ET TBIMMOPL.NUM_PLAN = "02"
OU
Si TBIMMOPL.TYPE_AMORT = "DEG" pour TBIMMOPL.NUM_PLAN = "01" ET TBIMMOPL.NUM_PLAN = "02"
je veux faire ma sélection totale qu'avec NUM_PLAN = "01" ...

Je ne vois pas trop comment faire, ça me fait un peu peur aussi lol ...
si vous avez quelques idées ...

Merci d'avance