Bonjour à tous, je travaille sur un projet qui consiste à compter le nombre de ventes par transaction sur une base de données Oracle 9i.
Je dois compter le nombre de ventes, le nombre de retours, le nombre de tickets de ventes et le nombre de tickets de retours. Voici ma requête :
--------------------------------------------------------------------------
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
40
41
42
43 SELECT HC.CODEMAGASIN, HC.CODEVENDEUR, (Select count(hc1.typedevente) from historique_caisses hc1 where hc1.codemagasin = HC.CODEMAGASIN and hc1.codevendeur = HC.CODEVENDEUR and hc1.typedevente = 1 and hc1.typeligne = 1 and hc1.codeinternearticle >= 50000 and hc1.ticketannule = 0 and hc1.jourdevente like to_date('30/06/2008','DD/MM/YYYY')) AS NBARTICLESVENDUS, (Select count(hc2.typedevente) from historique_caisses hc2 where hc2.codemagasin = HC.CODEMAGASIN and hc2.codevendeur = HC.CODEVENDEUR and hc2.typedevente = 1 and hc2.typeligne = 2 and hc2.codeinternearticle >= 50000 and hc2.ticketannule = 0 and hc2.jourdevente like to_date('30/06/2008','DD/MM/YYYY')) AS NBARTICLESRETOURNES, (select count(distinct hc3.numticket) from historique_caisses hc3 where hc3.codemagasin = hc.codemagasin and hc3.codevendeur = hc.codevendeur and hc3.typedevente = 1 and hc3.codeinternearticle >= 50000 and hc3.typeligne = 1 and hc3.ticketannule = 0 and hc3.jourdevente like to_date('30/06/2008','DD/MM/YYYY')) AS NBTICKETSVENTES, (select count(distinct hc4.numticket) from historique_caisses hc4 where hc4.codemagasin = hc.codemagasin and hc4.codevendeur = hc.codevendeur and hc4.typedevente = 1 and hc4.codeinternearticle >= 50000 and hc4.typeligne = 2 and hc4.ticketannule = 0 and hc4.jourdevente like to_date('30/06/2008','DD/MM/YYYY')) AS NBTICKETSRETOURS FROM HISTORIQUE_CAISSES HC WHERE HC.CODEMAGASIN >= 33 AND HC.CODEINTERNEARTICLE >= 50000 AND HC.TYPELIGNE IN (1,2) AND HC.JOURDEVENTE LIKE TO_DATE('30/06/2008','DD/MM/YYYY') GROUP BY HC.CODEMAGASIN,HC.CODEVENDEUR
Cette requête fonctionne mais me paraît un peu trop lourde en traitement.
Est-ce qu'il y a un moyen d'optimiser cette dernière ?
Merci pour vos réponses.
Partager