Bonjour,
J'ai la requête suivante qui fait une union de deux tables:
Par contre elle me génère des doublons, alors j'ai essayé de faire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 select npordn as ORDNO, max(npcvnb) as C6CVNB from neg006p where npordn <> '' group by npordn union select ordn as ORDNO, max(sdmd) as C6CVNB from dmdrefrq where sdmd in ( select c6cvnb from mbc6rep where c6dccd='1') and ordn like 'P%' group by ordn
En clair je reprends la même requête dont j'extrais ORDNO et la valeur max de C6CVNB, mais j'ai un message d'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 select ORDNO, max(C6CVNB) as c6cvnb from (select npordn as ORDNO, max(npcvnb) as C6CVNB from neg006p where npordn <> '' group by npordn union select ordn as ORDNO, max(sdmd) as C6CVNB from dmdrefrq where sdmd in ( select c6cvnb from mbc6rep where c6dccd='1') and ordn like 'P%' group by ordn ) group by ORDNO
Serveur*: Msg 156, Niveau 15, État 1, Ligne 13
Syntaxe incorrecte vers le mot clé 'group'.
Une idée?
Partager