Bonjour,

Je suis débutant en SQL et je n'arrive pas à réaliser une requête SQL.
En effet, je voudrais améliorer un petit intranet qui gère des projets et je voudrais rajouter une option qui filtre tous les projets sans "commandes"

Voici la requête de base:

Code : 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
26
27
28
29
sSQL = "SELECT Tb_Projets.idClient,isnull(Tb_Projets.invisibleEspaceClient,0) invisibleEspaceClient,Tb_Projets.id,societe,codeProjet,libProjet,modulesConcernes,dateDebut,avancement,categorieProjet,prioriteProjet,couleurFond,couleurTexte,sum(Tb_DetailProjets.nbJours) as nbJours,Tb_Projets.consultant,Tb_Projets.respProjet,Tb_Projets.dateDebutRecette,Tb_Projets.dateFinRecette,Tb_Projets.invisibleEspaceClient,convert(varchar,Tb_Projets.dateCloture,103) dateCloture,isnull(enqueteSatisfactRealisee,0) enqueteSatisfactRealisee "
		sSQL = sSQL & "	FROM Clients,Tb_Projets,Tb_DetailProjets"
		sSQL = sSQL & " WHERE Tb_Projets.idClient=Clients.Numéro"
		sSQL = sSQL & " AND Tb_DetailProjets.idProjet=Tb_Projets.id"
 
		if STADEPROJET="enCours" then
			sSQL = sSQL & " AND isnull(projetCloture,0)=0 "
		elseif STADEPROJET="clos" then
			sSQL = sSQL & " AND isnull(projetCloture,0)=1 "
		end if
 
		if STADEPLANIF="planifie" then
			sSQL = sSQL & " AND EXISTS (SELECT * FROM Tb_ProjetsChargesPrevisionnelles WHERE Tb_ProjetsChargesPrevisionnelles.idProjet=Tb_Projets.id AND isnull(Tb_ProjetsChargesPrevisionnelles.supprimee,0)=0)"
		elseif STADEPLANIF="nonPlanifie" then
			sSQL = sSQL & " AND NOT EXISTS (SELECT * FROM Tb_ProjetsChargesPrevisionnelles WHERE Tb_ProjetsChargesPrevisionnelles.idProjet=Tb_Projets.id AND isnull(Tb_ProjetsChargesPrevisionnelles.supprimee,0)=0)"
		end if
 
		if IDCLIENT<>"" then
			sSQL = sSQL & " AND Tb_Projets.idClient=" & IDCLIENT			
		end if
 
 
 
		if PROJETSANSCOMM="sansCommandes" then
		sSQL = //Code à compléter
		end if
 
		sSQL = sSQL & " GROUP BY Tb_Projets.idClient,Tb_Projets.id,societe,codeProjet,libProjet,modulesConcernes,dateDebut,avancement,categorieProjet,prioriteProjet,couleurFond,couleurTexte,Tb_Projets.consultant,Tb_Projets.respProjet,Tb_Projets.dateDebutRecette,Tb_Projets.dateFinRecette,Tb_Projets.invisibleEspaceClient,Tb_Projets.dateCloture,enqueteSatisfactRealisee "
		sSQL = sSQL & "	ORDER BY Clients.societe,dateDebut "

Pour cela je fais appel à 2 tables ci-joint :

Nom : Capture2.PNG
Affichages : 153
Taille : 20,3 Ko Nom : Capture.PNG
Affichages : 124
Taille : 4,4 Ko