Bonjour,
Mon problème est le suivant je souhaiterais avoir un retour égal à 0 quand il n'y a rien dans le COUNT de ma requête.
J'ai déjà trouvé une discussion parlant de cela j'ai essayé d'appliquer la solution proposée mais je n'y arrive pas.
Voici ma requête d'origine :
Code SQL : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 SELECT COUNT(T.objet.numero) AS mvt, T.magasin.identifiant, DatePart('ww',T.objet.date,2,1)-1 AS nsemaine FROM (SELECT objet.numero , magasin.identifiant, objet.date FROM objet INNER JOIN (magasin INNER JOIN m_s_o ON magasin.identifiant = m_s_o.identifiant) ON objet.numero = m_s_o.numero WHERE objet.Mvt = 101 UNION ALL SELECT objet.numero, magasin.identifiant, objet.date FROM objet INNER JOIN (magasin INNER JOIN m_s_o ON magasin.identifiant = m_s_o.identifiant) ON objet.numero = m_s_o.numero WHERE objet.Mvt = 281 ) AS T GROUP BY T.magasin.identifiant, DatePart('ww',T.objet.date,2,1)-1 ORDER BY DatePart('ww',T.objet.date,2,1)-1;
Voici le lien de la discussion qui m'a inspiré :
http://www.developpez.net/forums/d15...her-count-0-a/
Voici ma tentative de solution :
Code SQL : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 SELECT COUNT(T.objet.numero) AS mvt, T.magasin.identifiant, DatePart('ww',T.objet.date,2,1)-1 AS nsemaine FROM ( SELECT objet.numero , magasin.identifiant, objet.date FROM objet RIGHT JOIN (magasin RIGHT JOIN m_s_o ON magasin.identifiant = m_s_o.identifiant) ON objet.numero = m_s_o.numero AND WHERE objet.Mvt = 101 UNION ALL SELECT objet.numero, magasin.identifiant, objet.date FROM objet RIGHT JOIN (magasin RIGHT JOIN m_s_o ON magasin.identifiant = m_s_o.identifiant) ON objet.numero = m_s_o.numero AND WHERE objet.Mvt = 281 ) AS T GROUP BY T.magasin.identifiant, DatePart('ww',T.objet.date,2,1)-1 ORDER BY DatePart('ww',T.objet.date,2,1)-1;
Cela me renvoie erreur de synthase opérateur absent dans l'expression. Après je ne suis pas sûr qu'il faut des RIGHT JOIN.
Voici les tables de mes sous requêtes :
Merci d'avance pour votre aide
Partager