一条sql,有分页,表合并查询,多表连接,用于oracle数据库
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一条sql,有分页,表合并查询,多表连接,用于oracle数据库相关的知识,希望对你有一定的参考价值。
SELECT * FROM (
SELECT TT.*,ROWNUM RN FROM
( SELECT
A.CASE_ID AS TREATID,
A.TYPE AS TYPE,
B.CONTENT AS CONTENT,
B.ADD_USER_ID AS ADDUSERID,
B.Add_User_Type AS ADDUSERTRPE,
A.CREATE_TIME AS CREATETIME,
B.CHECK_TIME as CHECKTIME,
E.ADDUSERTYPE
FROM T_MEDICAL_CASE A
LEFT JOIN T_TREATMENT B ON A.CASE_ID = B.TREAT_ID
LEFT JOIN (select C.PATIENT_ID AS ID, C.USER_NAME, ‘2‘ AS ADDUSERTYPE
from T_PATIENT_INFO C
UNION
select D.DOCTOR_ID AS ID, D.USER_NAME, ‘1‘ AS ADDUSERTYPE
from T_DOCTOR_INFO D) E ON B.ADD_USER_ID = E.ID
WHERE A.PATIENT_ID = v_userid ORDER BY A.CREATE_TIME DESC) TT WHERE ROWNUM <=v_maxPage ) WHERE RN >=v_minPage;
以上是关于一条sql,有分页,表合并查询,多表连接,用于oracle数据库的主要内容,如果未能解决你的问题,请参考以下文章