Bonjour,
Je travaille sur de la GPAO. Je cherche à calculer le prix d'inventaire d'un type d'article à partir de son "coût matière". Pour cela, j'ai calculé le "coût matière" pour chaque matière de la gamme opératoire.
A présent je dois consolider ces coûts par article utilisant la gamme.
Malheureusement, je coince un peu en SQL. Je précise que je suis sous Oracle 10g.
Voici la requête qui calcule le coût matière par gamme:
Voici la requête qui me permet d'extraire les articles utilisant ces gammes :
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 select tmp.id_routing,sum(tmp.cout_pour_un) from (select b1.* from toperp.V_TRT_UNIT_BESOIN_ACHAT b1 union select b2.* from toperp.V_TRT_UNIT_CDE_BES_ACHAT b2 union select b3.* from toperp.V_TRT_UNIT_BES_CDE_ACHAT b3 union select b4.* from toperp.V_TRT_UNITTOT_BESOIN_ACHAT b4 union select b5.* from toperp.V_TRT_UNITTOT_BESAB1_ACHAT b5 union select b6.* from toperp.V_TRT_UNITTOT_BESAB2_ACHAT b6 union select b7.* from toperp.V_TRT_UNIT_TOLE_1 b7 union select b8.* from toperp.V_TRT_UNIT_TOLE_2 b8 union select b9.* from toperp.V_TRT_UNIT_TOLE_3 b9 union select b10.* from toperp.V_TRT_UNIT_TOLE_4 b10 union select b11.* from toperp.V_TRT_UNIT_TOLE_5 b11 union select b12.* from toperp.V_TRT_BES_M_MM b12 union select b20.* from toperp.V_TRT_MAT_SANS_LIV b20 ) tmp group by tmp.id_routing
Le but étant de :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 select a.id_article, o.id_routing from toperp.t_article a, toppdm.object o , toppdm.routing_material m where a.b_prod = -1 and a.id_famille = 385 and a.id_type_article = 1 and a.id_object = o.id_object and o.type = 47
1. faire la jointure entre la dernière requête est la première sur id_routing,
2. remonter la somme de cout_pour_un par a.id_article.
Merci d'avance.
Julien.
Partager