SELECT P.USERID AS "userId",
P.BID AS "BID",
udi.Age AS "Age",
cer.TYPE AS "Type",
CASE
when cer.TYPE = 1 THEN
'低级'
when cer.TYPE = 2 THEN
'中级'
when cer.TYPE = 3 THEN
'高级'
else '低级' end AS "TYPEName",
edu.EDUCATION AS "education"
FROM PABCD P
LEFT JOIN userdetailinfo udi
ON udi.userid = P.userid
LEFT JOIN (
SELECT *
FROM (
SELECT USERID,
TYPE,
ROW_NUMBER() OVER (
PARTITION BY USERID
ORDER BY
TYPE DESC
) AS "ROWNUM"
FROM CABCD
WHERE CERTTYPE = 3
)
WHERE "ROWNUM" = 1
) cer ON cer.userid = P.userid
LEFT JOIN (
SELECT USERID,
EDUCATIONTYPE,
EDUCATION
FROM EABCD
WHERE EDUCATIONTYPE = 4
) edu ON edu.userid = P.userid
WHERE P.BID = #{BID,jdbcType=VARCHAR}
oracle left join 连表时右表多条数据筛选的方法
最新推荐文章于 2024-08-16 17:27:28 发布