OVH Cloud OVH Cloud

Probleme de requete

2 réponses
Avatar
yannick
Bonsoir à tous,
Peut-on creer un seule requete lorsque l'on fait des totaux des totaux

c'est à dire j'ai: ma requete1 qui 'appelle qrys1 et ma requete2 qrys2

qrys1:
SELECT CommandeF_Detail.Numcde, CommandeF_Detail.Quantité,
CommandeF_Detail.Prix, CommandeF_Detail.PrixCd, [quantité]*[prix] AS
totalctge, [quantité]*[prixcd] AS totalcde,
(IIf([totalcde]<>0,[totalcde],[totalctge])) AS total
FROM CommandeF_Detail;

qrys2:
SELECT qrys1.Numcde, Sum(qrys1.total) AS totalNcde
FROM qrys1
GROUP BY qrys1.Numcde;

qrys2 s'appuie sur le resultat de qrys1

Peut on former qu'une seule requete?

Merci pour tous renseignements.

Bonne soirée

Yannick

2 réponses

Avatar
G Roydor
essayez ! mais sans garantie !



SELECT
CommandeF_Detail.Numcde,Sum(IIf([quantité]*[prixcd]<>0,[quantité]*[prixcd],[quantité]*[prix]))
as total
FROM CommandeF_Detail
GROUP BY CommandeF_Detail.Numcde;

GR

yannick a écrit:
Bonsoir à tous,
Peut-on creer un seule requete lorsque l'on fait des totaux des totaux

c'est à dire j'ai: ma requete1 qui 'appelle qrys1 et ma requete2 qrys2

qrys1:
SELECT CommandeF_Detail.Numcde, CommandeF_Detail.Quantité,
CommandeF_Detail.Prix, CommandeF_Detail.PrixCd, [quantité]*[prix] AS
totalctge, [quantité]*[prixcd] AS totalcde,
(IIf([totalcde]<>0,[totalcde],[totalctge])) AS total
FROM CommandeF_Detail;

qrys2:
SELECT qrys1.Numcde, Sum(qrys1.total) AS totalNcde
FROM qrys1
GROUP BY qrys1.Numcde;

qrys2 s'appuie sur le resultat de qrys1

Peut on former qu'une seule requete?

Merci pour tous renseignements.

Bonne soirée

Yannick






Avatar
yannick
bonsoir,
Sympa, cela fonctionne?

Je te remercie.

@+

Yannick




essayez ! mais sans garantie !



SELECT
CommandeF_Detail.Numcde,Sum(IIf([quantité]*[prixcd]<>0,[quantité]*[prixcd],[quantité]*[prix]))
as total
FROM CommandeF_Detail
GROUP BY CommandeF_Detail.Numcde;

GR

yannick a écrit:
Bonsoir à tous,
Peut-on creer un seule requete lorsque l'on fait des totaux des totaux

c'est à dire j'ai: ma requete1 qui 'appelle qrys1 et ma requete2 qrys2

qrys1:
SELECT CommandeF_Detail.Numcde, CommandeF_Detail.Quantité,
CommandeF_Detail.Prix, CommandeF_Detail.PrixCd, [quantité]*[prix] AS
totalctge, [quantité]*[prixcd] AS totalcde,
(IIf([totalcde]<>0,[totalcde],[totalctge])) AS total
FROM CommandeF_Detail;

qrys2:
SELECT qrys1.Numcde, Sum(qrys1.total) AS totalNcde
FROM qrys1
GROUP BY qrys1.Numcde;

qrys2 s'appuie sur le resultat de qrys1

Peut on former qu'une seule requete?

Merci pour tous renseignements.

Bonne soirée

Yannick