[合集] To get the 2nd, 3rd, 4th largest value# Database - 数据库
E*i
1 楼
☆─────────────────────────────────────☆
yiyayiyayo (Mera naam Itiaan hai) 于 (Wed May 16 23:34:48 2007) 提到:
It is pretty easy to get the largest value of a field. e.g.:
select max(salary) from employees;
How do you get the 2nd largest value? Or the 3rd largest?
Do this:
select salary, rn from
(select salary, row_number() over (order by salary desc) rn
from employees) x
where rn=2;
☆─────────────────────────────────────☆
q101 (^(?:[DX]?HT|X|YA)ML$) 于 (Wed May 16 23:44:23 2007) 提到:
yiyayiyayo (Mera naam Itiaan hai) 于 (Wed May 16 23:34:48 2007) 提到:
It is pretty easy to get the largest value of a field. e.g.:
select max(salary) from employees;
How do you get the 2nd largest value? Or the 3rd largest?
Do this:
select salary, rn from
(select salary, row_number() over (order by salary desc) rn
from employees) x
where rn=2;
☆─────────────────────────────────────☆
q101 (^(?:[DX]?HT|X|YA)ML$) 于 (Wed May 16 23:44:23 2007) 提到: