Syntaxe Incorrecte vers le mot clé 'WITH'

Résolu/Fermé
andyajram Messages postés 155 Date d'inscription vendredi 24 mai 2013 Statut Membre Dernière intervention 8 avril 2020 - 13 mars 2018 à 15:43
andyajram Messages postés 155 Date d'inscription vendredi 24 mai 2013 Statut Membre Dernière intervention 8 avril 2020 - 14 mars 2018 à 10:42
Bonjour, tout le monde j'ai une problème, quand j’exécute une requête sur SQL server 2014 elle marche bien mais sur SQL server 2005 ca me donne l'erreur Syntaxe incorrecte vers le mot clé 'WITH'.
voici ma requête:


WITH TMP AS (
SELECT INWI.Date ,
Equipe_Cad.MatBCC,
INWI.Matricule_FS,
Equipe_Cad.Employe,
Equipe_Cad.Equipe,Equipe_Cad.Societe,
Projet.Projet,
INWI.Quantite,
RIGHT('0' + INWI.Tps_Net, 9) C
FROM INWI
INNER JOIN Equipe_Cad ON INWI.Matricule_FS=Equipe_Cad .MatFS
INNER JOIN Projet ON Projet.EtapeTraitement='INWI_PREPAID'

WHERE INWI.Date = '02/03/2018'
)
SELECT Date ,
MatBCC AS Matricule_BCC,
Matricule_FS,Employe AS Nom,Equipe,Societe,
Projet,
CAST(SUM(Quantite)AS int)AS Quantite ,
SUM(CAST(LEFT(C, 2) AS DECIMAL(10,8)) +
CAST(SUBSTRING(C, 4, 2) AS DECIMAL(10,8)) / 60 +
CAST(SUBSTRING(C, 7, 2) AS DECIMAL(10,8)) / 3600) AS Temps_Effectif
FROM TMP
GROUP BY Date, MatBCC ,Matricule_FS,Employe ,Equipe,Projet,Societe


merci d'avance

A voir également:

3 réponses

jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
13 mars 2018 à 20:56
Bonjour

Comme indiqué dans la doc .. ne marche qu'à partir de 2008.
0
andyajram Messages postés 155 Date d'inscription vendredi 24 mai 2013 Statut Membre Dernière intervention 8 avril 2020
13 mars 2018 à 21:00
C'est bon j'ai résolu le problème en changeant la requête comme ça :
  
SELECT
x.Date,
x.MatBCC AS Matricule_BCC,
x.Matricule_FS,x.Employe AS Nom,x.Equipe,x.Societe,
x.Projet,
CAST(SUM(x.Quantite)AS int)AS Quantite ,
SUM(CAST(LEFT(x.C, 2) AS DECIMAL(10,8)) +
CAST(SUBSTRING(x.C, 4, 2) AS DECIMAL(10,8)) / 60 +
CAST(SUBSTRING(x.C, 7, 2) AS DECIMAL(10,8)) / 3600) AS Temps_Effectif
FROM
(
SELECT
INWI.Date ,
Equipe_Cad.MatBCC,
INWI.Matricule_FS,
Equipe_Cad.Employe,
Equipe_Cad.Equipe,Equipe_Cad.Societe,
Projet.Projet,
INWI.Quantite,
RIGHT('0' + INWI.Tps_Net, 9) C
FROM
INWI
INNER JOIN
Equipe_Cad ON INWI.Matricule_FS = Equipe_Cad .MatFS
INNER JOIN
Projet ON Projet.EtapeTraitement = 'INWI_PREPAID'
WHERE
INWI.Date = '02/03/2018') AS x
GROUP BY
x.Date, x.MatBCC, x.Matricule_FS, x.Employe, x.Equipe, x.Projet, x.Societe
0
andyajram Messages postés 155 Date d'inscription vendredi 24 mai 2013 Statut Membre Dernière intervention 8 avril 2020
Modifié le 14 mars 2018 à 10:45
j'ai un autre problème s'il vous plaît, c'est quoi le type qui remplace time dans SQL 2005 parcequ'il n'accepte pas Time comme type quand je veux executer la requête?
 SELECT convert(datetime, convert(char(8), Date)) AS Date,E.MatBCC,C.Mat AS MatFS,E.Employe As Nom,E.Equipe,E.Societe,P.Projet, 
DATEDIFF(SECOND, 0, CAST(Temps AS time))/3600. As Temps_Effectif from Cadences C,Equipe_Cad E,Projet_Cad P
where C.Mat= E.MatFS AND C.EtapeTraitement= P.EtapeTraitement AND NOT (E.Equipe = 'Prep. CHQ' and P.Projet= 'PREPARATION CHQ')
AND NOT (E.Equipe = 'Prep. CIH' and P.Projet= 'PREPARATION CHQ') AND C.Date like '20180305'

group by C.Date,C.Mat,E.MatBCC,E.Employe ,E.Equipe,C.EtapeTraitement,C.Temps,P.Projet,E.Societe


le problème est dans DateDIFF(SECOND,0,CAST(Temps AS time))/3600.
0