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
| SQL> select * from match order by 1,2;
EQUIPE POINTS
-------------------- ----------
BORDEAUX 0
BORDEAUX 3
BORDEAUX 3
MARSEILLE 0
MARSEILLE 0
MARSEILLE 0
MARSEILLE 1
MARSEILLE 1
MARSEILLE 3
MARSEILLE 3
PARIS 0
EQUIPE POINTS
-------------------- ----------
PARIS 0
PARIS 3
13 rows selected.
SQL> WITH m AS (
2 SELECT equipe , points , case when points =3 then 'Victoire'
3 when points=1 then 'Null'
4 else 'Defaite' end resultat
5 FROM match)
6 SELECT DISTINCT equipe ,resultat, count(*)over(partition BY equipe,resultat) Nombre FROM m
7 ORDER BY 1,2 ;
EQUIPE RESULTAT NOMBRE
-------------------- -------- ----------
BORDEAUX Defaite 1
BORDEAUX Victoire 2
MARSEILLE Defaite 3
MARSEILLE Null 2
MARSEILLE Victoire 2
PARIS Defaite 2
PARIS Victoire 1
7 rows selected.
SQL> |