maxpouliot
12-01-2009, 02:40 PM
Hi, the following query works :
SELECT DISTINCT(envois_employes.employes), employes.nomComplet,COUNT(envoi) AS totalEnvois,(SELECT COUNT(envoi) AS clics FROM envois_employes WHERE visite=true AND employes =employes.id) AS totalClics, totalClics/totalEnvois AS pourcentage FROM envois_employes INNER JOIN employes ON envois_employes.employes = employes.id GROUP BY envois_employes.employes, employes.nomComplet, employes.id
But if i add ORDER BY pourcentage i get the following error : ORDER BY clause (pourcentage) conflicts with DISTINCT
Can anybody tell me what do i have to do?
Thanks
Edit : Just found out that i don't need the DISTINCT, but my ORDER By pourcentage still doesn't work
Edit 2 :
SELECT envois_employes.employes, employes.nomComplet,COUNT(envoi) AS totalEnvois,(SELECT COUNT(envoi) AS totalClics FROM envois_employes WHERE visite=true AND employes =employes.id) AS CLIC, clic/totalEnvois AS pourcentage FROM envois_employes INNER JOIN employes ON envois_employes.employes = employes.id GROUP BY envois_employes.employes, employes.nomComplet, employes.id ORDER BY "pourcentage"
Does not give me an error but doesn't really Order By
SELECT DISTINCT(envois_employes.employes), employes.nomComplet,COUNT(envoi) AS totalEnvois,(SELECT COUNT(envoi) AS clics FROM envois_employes WHERE visite=true AND employes =employes.id) AS totalClics, totalClics/totalEnvois AS pourcentage FROM envois_employes INNER JOIN employes ON envois_employes.employes = employes.id GROUP BY envois_employes.employes, employes.nomComplet, employes.id
But if i add ORDER BY pourcentage i get the following error : ORDER BY clause (pourcentage) conflicts with DISTINCT
Can anybody tell me what do i have to do?
Thanks
Edit : Just found out that i don't need the DISTINCT, but my ORDER By pourcentage still doesn't work
Edit 2 :
SELECT envois_employes.employes, employes.nomComplet,COUNT(envoi) AS totalEnvois,(SELECT COUNT(envoi) AS totalClics FROM envois_employes WHERE visite=true AND employes =employes.id) AS CLIC, clic/totalEnvois AS pourcentage FROM envois_employes INNER JOIN employes ON envois_employes.employes = employes.id GROUP BY envois_employes.employes, employes.nomComplet, employes.id ORDER BY "pourcentage"
Does not give me an error but doesn't really Order By