Oracle铅/最后函数

  

1。语法

凹坠俏那?最后函数"

目的

,

第一个和最后一个非常相似的功能。都聚集和分析>操作的函数最小值(job_id),保持(dense_rank  first  order  bycount (job_id), desc),在(partition  by  department_id)

<强>

<强> min A3B3minAmaxBAVGinvalid numbermaxmin

<强>保持

<强> dense_rank row_number

<强>/ overaggregate

3。

1.1

select 马克斯(e.job_id),保持(dense_rank  lastorder  by 计数(job_id), desc),   ,,,,,min (e.job_id),保持(dense_rank  last  order  by 计数(job_id), desc),   ,,,,,马克斯(e.job_id),保持(dense_rank  first  order  by 计数(job_id), desc),   ,,,,,min (e.job_id),保持(dense_rank  first  order  by 计数(job_id), desc)   得到employees  e   ,group  by  e.department_id, e.job_id;

SA_REP AC_ACCOUNT ,,,SA_REP SA_REP

2.2最大最小

select 截然不同   ,,,,,department_id,   ,,,,,,计数(job_id),   ,,,,,min (job_id),保持(dense_rank  first  order  by 计数(job_id), desc)/(partition  by  department_id), job_id   得到员工   ,group  by  department_id job_id   ,order  by  1;

1,,,,,,,,,,,,,10个,,,,,,,,,,AD_ASST

2,,,,,,,,,,,,,20,,,,,,,,,,MK_MAN

3,,,,,,,,,,,,,30,,,,,,,,,,PU_CLERK

4,,,,,,,,,,,,,40岁,,,,,,,,,,HR_REP

5,,,,,,,,,,,,,50个,,,,,,,,,,SH_CLERK

6,,,,,,,,,,,,,60岁,,,,,,,,,,IT_PROG

7,,,,,,,,,,,,,70,,,,,,,,,,PR_REP

8,,,,,,,,,,,,,80,,,,,,,,,,SA_REP

9,,,,,,,,,,,,,90,,,,,,,,,,AD_VP

10,,,,,,,,,,100,,,,,,,,FI_ACCOUNT

11,,,,,,,,,,110,,,,,,,,AC_ACCOUNT

12,,,,,,,,,,,,,,,,,,,,,,,,,,SA_REP IDboss

3。

1。方法1

with  t    ,,,(select  department_id job_id,,数(job_id)问   ,才能得到员工   group 才能;by  department_id, job_id)   select  department_id,马克斯(job_id),,,再次聚合   得到t   ,where  (department_id,,问),拷贝(selectdepartment_id,马克斯(问),得到t  group  by  department_id)   group  by  department_id   ,order  by  1;

1,,,,,,,,,,,,,10个,,,,,,,,,,AD_ASST

2,,,,,,,,,,,,,20,,,,,,,,,,MK_REP

3,,,,,,,,,,,,,30,,,,,,,,,,PU_CLERK

4,,,,,,,,,,,,,40岁,,,,,,,,,,HR_REP

5,,,,,,,,,,,,,50个,,,,,,,,,,null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

Oracle铅/最后函数