Précédent   Forum des professionnels en informatique > Bases de données > Oracle > PL/SQL
PL/SQL Forum d'entraide sur le PL/SQL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 06/08/2011, 20h04   #1
Invité de passage
 
pedro pedro
Inscription : août 2010
Messages : 6
Détails du profil
Informations personnelles :
Nom : pedro pedro

Informations forums :
Inscription : août 2010
Messages : 6
Points : 1
Points : 1
Par défaut regroupement de ligne en plsql

Bonjour,

j'ai besoin de votre aide.

j'ai une table qui contient 3 colonnes : rayon ; niveau ; achats. voici un exemple de la table

rayon | niveau | achats
---------------------------------------

A | a1 | 10
C | c1 | 20
A | a1 | 40
B | b1 | 10
B | b1 | 50
A | a2 | 30
C | c2 | 70
C | c2 | 20
A | a3 | 50

j'aimerais regrouper les même niveaux et avoir comme résultat avec un code en PL/SQL :


rayon | niveau | achats
---------------------------------------

A | a1 | 50
A | a2 | 30
A | a3 | 50
B | b1 | 60
C | c1 | 20
C | c2 | 90

j'ai essayé de faire deux curseurs pour comparer les deux colonnes rayon et niveau avec des groupe by mais ça marche pas.

Merci de bien m'aider
pedro0077 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/08/2011, 09h59   #2
Membre expérimenté
 
Homme Mohamed Houri
Inscription : mars 2010
Messages : 286
Détails du profil
Informations personnelles :
Nom : Homme Mohamed Houri
Localisation : France

Informations forums :
Inscription : mars 2010
Messages : 286
Points : 563
Points : 563
Code :
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
mohamed@mhouri> INSERT INTO tab1 VALUES ('A','a1', 10);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('A','a1', 40);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('A','a2', 30);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('A','a3', 50);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('B','b1', 10);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('B','b1', 50);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('C','c1', 20);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('C','c2', 20);
 
1 ligne créée.
 
mohamed@mhouri> INSERT INTO tab1 VALUES ('C','c2', 70);
 
1 ligne créée.
 
mohamed@mhouri> commit;
 
Validation effectuée.
 
mohamed@mhouri> SELECT * FROM tab1;
 
RAY NIV      ACHAT                                                              
--- --- ----------                                                              
A   a1          10                                                              
A   a1          40                                                              
A   a2          30                                                              
A   a3          50                                                              
B   b1          10                                                              
B   b1          50                                                              
C   c1          20                                                              
C   c2          20                                                              
C   c2          70                                                              
 
9 ligne(s) sélectionnée(s).
 
 
mohamed@mhouri> SELECT rayon, niveau, sum(achat)
  2  FROM tab1
  3  GROUP BY rayon, niveau
  4  ORDER BY rayon, niveau;
 
RAY NIV SUM(ACHAT)                                                              
--- --- ----------                                                              
A   a1          50                                                              
A   a2          30                                                              
A   a3          50                                                              
B   b1          60                                                              
C   c1          20                                                              
C   c2          90                                                              
 
6 ligne(s) sélectionnée(s).
Mohamed Houri
Mohamed.Houri est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h50.


 
 
 
 
Partenaires

Hébergement Web