Probleme UNION ALL

Le
Julien Bonnier
Bonjours tlm,

J'ai un probleme avec une requete UNION qui est la suivante:

SELECT 'DEP' AS Dept,'FAM' AS Famille,'STYLE' AS Style,'WOO' AS
S01WOO0QTE,'WOO' AS S01WOO1SAL,'WOO' AS S01WOO2PRF,'MAD' AS S11MAD0QTE,'MAD'
AS S11MAD1SAL,'MAD' AS S11MAD2PRF,'MIA' AS S18MIA0QTE,'MIA' AS
S18MIA1SAL,'MIA' AS S18MIA2PRF,'STL' AS S20STL0QTE,'STL' AS S20STL1SAL,'STL'
AS S20STL2PRF,'LAM' AS S21LAM0QTE,'LAM' AS S21LAM1SAL,'LAM' AS
S21LAM2PRF,'TOR' AS S40TOR0QTE,'TOR' AS S40TOR1SAL,'TOR' AS S40TOR2PRF,'PAR'
AS S70PAR0QTE,'PAR' AS S70PAR1SAL,'PAR' AS S70PAR2PRF,'TOT' AS
S99TOT0QTE,'TOT' AS S99TOT1SAL,'TOT' AS S99TOT2PRF

ORDER BY Dept, Famille, Style

UNION ALL

SELECT St.Dept, St.Famille, St.Style
,Q.S01WOO0QTE,S.S01WOO1SAL,P.S01WOO2PRF,Q.S11MAD0QTE,S.S11MAD1SAL,P.S11MAD2PRF,Q.S18MIA0QTE,S.S18MIA1SAL,P.S18MIA2PRF,Q.S20STL0QTE,S.S20STL1SAL,P.S20STL2PRF,Q.S21LAM0QTE,S.S21LAM1SAL,P.S21LAM2PRF,Q.S40TOR0QTE,S.S40TOR1SAL,P.S40TOR2PRF,Q.S70PAR0QTE,S.S70PAR1SAL,P.S70PAR2PRF,Q.S99TOT0QTE,S.S99TOT1SAL,P.S99TOT2PRF
FROM ut_RptSalesCumulStyle AS St

LEFT JOIN ut_RptRetailSalesCumulQte AS Q ON St.Style=Q.Style

LEFT JOIN ut_RptRetailSalesCumulSales AS S ON St.Style=S.Style

LEFT JOIN ut_RptRetailSalesCumulProfit AS P ON St.Style=P.Style

WHERE Q.S99TOT0QTE IS NOT NULL

ORDER BY St.Dept, St.Famille, St.Style



Elle me retourne :

Msg 156, Level 15, State 1, Line 3

Incorrect syntax near the keyword 'UNION'.



Quelqu'un vois quel est le probleme?





Julien
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Jean-Nicolas BERGER
Le #11853841
Bonsoir,
Il faut tout simplement enlever le 'ORDER BY' avant le UNION.
Cordialement.
JN BERGER


"Julien Bonnier"
Bonjours tlm,

J'ai un probleme avec une requete UNION qui est la suivante:

SELECT 'DEP' AS Dept,'FAM' AS Famille,'STYLE' AS Style,'WOO' AS
S01WOO0QTE,'WOO' AS S01WOO1SAL,'WOO' AS S01WOO2PRF,'MAD' AS
S11MAD0QTE,'MAD' AS S11MAD1SAL,'MAD' AS S11MAD2PRF,'MIA' AS
S18MIA0QTE,'MIA' AS S18MIA1SAL,'MIA' AS S18MIA2PRF,'STL' AS
S20STL0QTE,'STL' AS S20STL1SAL,'STL' AS S20STL2PRF,'LAM' AS
S21LAM0QTE,'LAM' AS S21LAM1SAL,'LAM' AS S21LAM2PRF,'TOR' AS
S40TOR0QTE,'TOR' AS S40TOR1SAL,'TOR' AS S40TOR2PRF,'PAR' AS
S70PAR0QTE,'PAR' AS S70PAR1SAL,'PAR' AS S70PAR2PRF,'TOT' AS
S99TOT0QTE,'TOT' AS S99TOT1SAL,'TOT' AS S99TOT2PRF

ORDER BY Dept, Famille, Style

UNION ALL

SELECT St.Dept, St.Famille, St.Style
,Q.S01WOO0QTE,S.S01WOO1SAL,P.S01WOO2PRF,Q.S11MAD0QTE,S.S11MAD1SAL,P.S11MAD2PRF,Q.S18MIA0QTE,S.S18MIA1SAL,P.S18MIA2PRF,Q.S20STL0QTE,S.S20STL1SAL,P.S20STL2PRF,Q.S21LAM0QTE,S.S21LAM1SAL,P.S21LAM2PRF,Q.S40TOR0QTE,S.S40TOR1SAL,P.S40TOR2PRF,Q.S70PAR0QTE,S.S70PAR1SAL,P.S70PAR2PRF,Q.S99TOT0QTE,S.S99TOT1SAL,P.S99TOT2PRF
FROM ut_RptSalesCumulStyle AS St

LEFT JOIN ut_RptRetailSalesCumulQte AS Q ON St.Style=Q.Style

LEFT JOIN ut_RptRetailSalesCumulSales AS S ON St.Style=S.Style

LEFT JOIN ut_RptRetailSalesCumulProfit AS P ON St.Style=P.Style

WHERE Q.S99TOT0QTE IS NOT NULL

ORDER BY St.Dept, St.Famille, St.Style



Elle me retourne :

Msg 156, Level 15, State 1, Line 3

Incorrect syntax near the keyword 'UNION'.



Quelqu'un vois quel est le probleme?





Julien




Publicité
Poster une réponse
Anonyme