1. 程式人生 > 其它 >linux篇-linux面試題彙總

linux篇-linux面試題彙總

名稱 描述 例子 結果

RANK()

當前行在其分割槽內的秩,帶間隙

select
	name,
	department,
	salary,
	rank() over (partition by department
order by
	salary) as value
from
	user;
DENSE_RANK() 當前行在其分割槽內的秩,沒有間隙
select
	name,
	department,
	salary,
	DENSE_RANK() over (partition by department
order by
	salary) as value
from
	user;
percent_rank() 百分比秩值,percent_rank() 含義就是 當前行-1 / 當前組總行數-1
select
	name,
	department,
	salary,
	PERCENT_RANK() over (partition by department
order by
	salary) as value
from
	user;
ROW_NUMBER() 分組內行號,有幾行就到幾
select
   name,
   department,
   salary,
   ROW_NUMBER() over (partition by department
order by
   salary) as value
from
   user;
FIRST_VALUE(column_name) 顯示指定列,分組後的第一行值
select
   name,
   department,
   salary,
   FIRST_VALUE(salary) over (partition by department
order by
   salary) as value
from
   user;