In Oracle, if there are 100 records, retrieve the 10th line to 20th lines, what is better?

xiaoxiao2021-03-06  40

Select * from (select Table. *, Row_Number () over (Order By Field) RK from Table) Where rk> = 10 and rK <= 20 =================== =========================== r_number function description: Return to the offset of a row in the ordered group, so that can be used in specific standards Line number. Sample: The following example returns each employee again in each department to sort the sequence number after the employee number

SELECT Department_ID, Last_Name, Employee_ID, Row_Number () over (partition by department_id order by Employee_ID) AS EMP_ID from Employeeswhere Department_ID <50;

Department_id last_name Employee_id Emp_ID ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- ---------- 10 Whalen 200 1 20 Hartstein 201 20 Fay 202 2 30 Raphaly 114 1 30 Khoo 115 2 30 Baida 116 3 30 Tobias 117 4 30 Himuro 118 5 ===== =====================================================================================================================================================================================38387

转载请注明原文地址:https://www.9cbs.com/read-60748.html

New Post(0)