Shurikn Posted September 26, 2004 Posted September 26, 2004 ok here's my request for now: SELECT tblUser.Nom, tblUser.Prenom, Sum(CréditsDeVente) as somme, tblUser.Societe, tblUser2.Nom, tblUser2.Prenom FROM tblUser, tblIndividus, tblProjet, tblUser as tblUser2 WHERE tblProjet.ProjetIndividu=tblIndividus.NomPrénom AND tblIndividus.IndividuChargéDeCompte=tblUser2.index AND tblIndividus.IndividuRessAffairesEst=tblUser.index AND Statut="Terminé - succès" GROUP BY tblUser.Nom, tblUser.Prenom, tblUser.Societe, tblUser2.Nom, tblUser2.Prenom ORDER BY Sum(CréditsDeVente) DESC, tblUser.Societe, tblUser.Nom, tblUser.Prenom but there is juste a problem, I want the data from the Individus who dont have a ChargéDeCompte in other words, all the data from wich this part: "AND tblIndividus.IndividuChargéDeCompte=tblUser2.index " does not exist. can anyone help me out on there? if you need more info ask... ill put an exemple soon... Quote
*Experts* Nerseus Posted September 27, 2004 *Experts* Posted September 27, 2004 You'll want to add something like this to the where clause: AND NOT EXISTS ( SELECT * FROM tblIndividus WHERE IndividuChargéDeCompte = tblUser2.index ) -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Joe Mamma Posted September 27, 2004 Posted September 27, 2004 MS-SQL, ACCESS, DB2, Sybase, Oracle 10g, this will work. . . and much faster than the not exists. wont work in Oracle 9 or earlier SELECT u1.Nom, u1.Prenom, Sum(CréditsDeVente) as somme, u1.Societe, u2.Nom, u2.Prenom FROM ( ( tblIndividus i inner join tblProjet p on i.NomPrénom = p.ProjetIndividu) inner join tblUser u1 on u1.index = i.IndividuRessAffairesEst ) left outer join tblUser u2 on u2.Index = i.IndividuRessAffairesEst where Statut="Terminé - succès" and u2.index is null GROUP BY u1.Nom, u1.Prenom, u1.Societe, u2.Nom, u2.Prenom ORDER BY Sum(CréditsDeVente) DESC, u1.Societe, u1.Nom, u1.Prenom Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.