Oracle数据库和DB2数据库分页SQL的区别举例

时间:2023-05-01 18:20:14
--------------------------ORACLE数据库分页SQL举例------------------------------------------------
SELECT *
FROM (
SELECT TEMP.*, ROWNUM AS NUM
FROM (
SELECT EB.EHR_ID,EB.PERSON_NAME,CL.SVC_ID a,BILL.SVC_ID b,BILL.ITEM_NAME
FROM PHIS.EHR_BASE EB, PHIS.SVC_CLINIC CL,PHIS.SVC_CLINIC_BILL BILL
WHERE EB.EHR_ID = CL.EHR_ID
AND CL.SVC_ID = BILL.SVC_ID
) TEMP
)
WHERE NUM <= 5
AND NUM > 0
--------------------------DB2数据库分页SQL举例---------------------------------------------------
SELECT *
FROM (
SELECT TEMP.*, ROW_NUMBER() OVER() AS NUM
FROM (
SELECT EB.EHR_ID,EB.PERSON_NAME,CL.SVC_ID a,BILL.SVC_ID b,BILL.ITEM_NAME
FROM PHIS.EHR_BASE EB, PHIS.SVC_CLINIC CL,PHIS.SVC_CLINIC_BILL BILL
WHERE EB.EHR_ID = CL.EHR_ID
AND CL.SVC_ID = BILL.SVC_ID
) TEMP
)
WHERE NUM <= 5
AND NUM > 0
-------------------------------------------------------------------------------------------------