• 周五. 9月 30th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

sql中关于case when的一个例子

admin

11月 28, 2021

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

发表回复

您的电子邮箱地址不会被公开。