且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将子查询添加到cte以从两个表中获取结果

更新时间:2023-11-30 20:01:40

select t.cust_ID,t.name, (CASE ISNULL(cte.lnode, 0) WHEN 1 THEN 'paid' ELSE 'not paid' END) lnode, (CASE ISNULL(cte.rnode, 0) WHEN 1 THEN 'paid' ELSE 'not paid' END)
rnode 
from  user_detail t 
      left join cte on cte.cust_ID = t.parentid 
where user_detail.cust_ID = 'YOUR_ID'