首页 > 代码库 > 一条带分页的sql
一条带分页的sql
SELECT *
FROM (SELECT USERID,
TYPE,
TYPE_DESC,
SEX,
USERNAME,
HEADPORTRAIT,
HOSPITAL,
HLEVEL,
DEPT,
JOBTITLE,
PRICE,
TIME,
INTRODUCE,
ISFRIEND,
ROWNUM rn
FROM (SELECT rownum R,
a.expert_id as USERID,
a.expert_id as TYPE,
b.type_desc as TYPE_DESC,
a.sex as SEX,
a.user_name as USERNAME,
a.head_portrait as HEADPORTRAIT,
h.hospital_name as HOSPITAL,
H.H_LEVEL AS HLEVEL,
c.jobtitle_name as JOBTITLE,
d.dept_name as DEPT,
e.price as PRICE,
e.time as TIME,
a.introduce as INTRODUCE,
CASE
WHEN (SELECT COUNT(*)
FROM T_GROUP_RELATION X
WHERE X.USER_ID = v_userId
AND X.FRIEND_ID = a.expert_id) > 0 THEN
1
ELSE
0
END AS ISFRIEND
from T_EXPERT_INFO a,
T_EXPERT_TYPE_INFO b,
T_JOBTITLE c,
T_HOSPITAL h,
T_DEPT d,
T_EXPERT_PRICE_INFO e
where a.expert_type = b.type_id
and a.jobtitle_id = c.jobtitle_id
and a.hospital_id = h.HOSPITAL_ID
and a.dept_id = d.dept_id
and e.expert_id = a.expert_id
ORDER BY a.create_time DESC)
WHERE ROWNUM <= page * pageSize)
WHERE rn >= ((page - 1) * pageSize) + 1;
一条带分页的sql