There are Scott users in Oracle 10g
Alter user Scott account unlock;
Use the Scott password Tiger to enter, change the password, change the user has an EMP table;
Rank function:
SELECT deptno, Job, SUM (SAL),
RANK () over (PARTITION by Deptno ORDER by
SUM (SAL) DESC)
As Jobdep_rank,rank () over (ORDER by SUM (SAL) DESC) as Sumsal_rank
From EMP
GROUP by Deptno, job;
< Span style= "font-family: ' The song Body '; >deptno |
job |
sum (SAL) |
jobdep_rank |
|
20 |
analyst |
6000 |
1 |
1 |
30 |
salesman |
5600 |
1 |
2 |
10 |
president |
5000 |
1 |
3 |
20 |
manager |
2975 |
2 |
4 |
30 |
manager |
2850 |
2 |
5 |
10 |
manager |
2450 |
2 |
6 |
20 |
clerk |
1900 |
3 |
7 |
10 |
clerk |
1300 |
3 |
8 |
30 |
Clerk |
950 |
3 |
9 |
Cume_dist
SELECT deptno, Job, SUM (SAL),
Cume_dist () over (PARTITION by Deptno ORDER by
SUM (SAL) DESC)
As CUME_DIST_PER_DEP
From EMP
GROUP by Deptno, job
ORDER by Deptno, SUM (SAL);
< Span style= "font-family: ' The song Body '; >deptno |
job |
sum (SAL) |
CUME_DIST_PER_DEP |
10 |
clerk |
1300 |
1 |
10 |
manager |
2450 |
0.666667 |
10 |
president |
5000 |
0.333333 |
20 |
clerk |
1900 |
1 |
20 |
manager |
2975 |
0.666667 |
20 |
analyst |
6000 |
0.333333 |
30 |
clerk |
950 |
1 |
30 |
manager |
2850 |
0.666667 |
30 |
Salesman |
5600 |
0.333333 |
With these two useful functions, the rankings and percentages will soon be available.
Oracle is useful for statistical functions rank and Cume