Pouvez vous m'aider une dernière fois car ma requête ne fonctionne pas
grand merci d'avance
Pouvez vous m'aider une dernière fois car ma requête ne fonctionne pas
grand merci d'avance
il manque une virgule avant @ qte=...DECLARE @ qte VARCHAR (8000)
SELECT ARTCODE ,
PLVDESIGNATION as 'Designation',
month( PCVDATEEFFET) AS Mois,
year( PCVDATEEFFET) AS Année,
sum(PLVQTE) as 'QTE VTE'
@ qte = COALESCE (@ qte + ',' , '' ) + ISNULL (qte, 'N/A')
from V_LST_PIECEVENTELIGNES
where pitcode ='F'
and AFMCODE = 'BLACKSTAR'
AND pcvdateeffet > dateadd(m,-12,getdate())
GROUP BY ARTCODE, PLVDESIGNATION, month( PCVDATEEFFET), year( PCVDATEEFFET)
Prendre conscience, c'est transformer le voile qui recouvre la lumière en miroir.
MCTS Database Development
MCTS Database Administration
Le but est de concaténer les QTE_VNT, donc il me semble qu'il faudrait d'abord générer la requête qui contient les champs Article, Description, QteVnt, Mois, Annee, puis ensuite faire une requête dessus pour la concaténation. (voir l'exemple de la deuxième partie dans le lien que j'ai posté avant)
...Mais j'ai vraiment pas le temps d'y regarder plus en profondeur pour l'instant, désolé.
pouvez vous m'aider une derniere fois
encore un grand merci
je vous joint le fichier résultat genere
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 SELECT ARTCODE , PLVDESIGNATION as 'Designation', month( PCVDATEEFFET) AS Mois, year( PCVDATEEFFET) AS Année, sum(PLVQTE) as 'QTE_VTE' from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' AND pcvdateeffet > dateadd(m,-12,getdate()) GROUP BY ARTCODE, PLVDESIGNATION, month( PCVDATEEFFET), year( PCVDATEEFFET) order by ARTCODE, year( PCVDATEEFFET), month( PCVDATEEFFET) DECLARE @qte_vte VARCHAR (8000) SELECT @qte_vte = COALESCE (@qte_vte + ',' , '' ) + ISNULL (@qte_vte, 'N/A') FROM V_LST_PIECEVENTELIGNES
pouvez vous me dire si je suis sur la bonne voie
pour obtenir un resultat comme suis sur les 12 derniers mois
code article, designation, qte vte-12, qte vte -11, qte vte -10, etc
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
30
31
32
33
34
35
36
37
38
39 SELECT distinct ARTCODE , PLVDESIGNATION , (select sum(PLVQTE) as 'QTE_VTE' from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' AND pcvdateeffet >= dateadd(m,-12,getdate()) AND pcvdateeffet <= dateadd(m,-11,getdate()) ), (select sum(PLVQTE) as 'QTE_VTE' from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' AND pcvdateeffet > dateadd(m,-2,getdate())), (select sum(PLVQTE) as 'QTE_VTE' from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' AND pcvdateeffet > dateadd(m,-3,getdate())), (select sum(PLVQTE) as 'QTE_VTE' from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' AND pcvdateeffet > dateadd(m,-4,getdate())), (select sum(PLVQTE) as 'QTE_VTE' from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' AND pcvdateeffet > dateadd(m,-5,getdate())) from V_LST_PIECEVENTELIGNES where pitcode ='F' and AFMCODE = 'BLACKSTAR' GROUP BY ARTCODE, PLVDESIGNATION
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager