Database Reference
In-Depth Information
Vue complexe d'une vue (
suite
)
Résultat (
suite
)
N_DEPT ID_EMPLOI
EFFECTIF
MONTANT
----------
---------- ------------ -----------
30 PU_CLERK
5
3000
30 PU_MAN
1
7000
40 HR_REP
1
5000
50 SH_CLERK
20
3000
50 ST_CLERK
20
2992
50 ST_MAN 5
3000
60 IT_PROG
5
6000
70 PR_REP
1
6000
80 SA_MAN 5
10080
80 SA_REP
29
6008
90 AD_PRES
1
19920
90 AD_VP
2
15000
100 FI_ACCOUNT
5
4800
100 FI_MGR
1
7800
110 AC_ACCOUNT
1
4800
110 AC_MGR
1
7800
La troisième vue cumule le salaire médian de chaque type d'emploi pour tout département.
Tableau 4-16 : Cumul par type d'emploi et département
Vue complexe d'une vue
Résultat
CREATE VIEW soutou.v_v_v_emps_cumul
(n_dept, id_emploi, cumul)
AS SELECT n_dept, id_emploi,
SUM(effectif*montant)
FROM soutou.v_v_job_emps
GROUP BY n_dept, id_emploi
ORDER BY 1,2;
SQL> SELECT n_dept, id_emploi, cumul
FROM soutou.v_v_v_emps_cumul;
N_DEPT
ID_EMPLOI
CUMUL
---------- -----------
----------
10 AD_ASST
3000
20 MK_MAN
6000
20 MK_REP 5000
30 PU_CLERK
15000
30 PU_MAN 7000
40 HR_REP 5000
50 SH_CLERK 60000
50 ST_CLERK
59840
50 ST_MAN 15000
60 IT_PROG
30000
70 PR_REP 6000