递归层级查询:start with connect by prior 以部门表作为解析 表结构:dept{id:'主键',name:'部门名称',parent_id:'父亲id'} select * from dept start with id=1 connect by prior id= parent_idorder siblings by id 分两部分理解: 第一步找出一条数据作为基础:select * from dept start with id =? 第二步prior放在左边还是…
需求:找出代理商中没有挂商家的代理商 简单SQL如下: select * from t_proxy tp where tp.id not in (SELECT tp.id as p_id FROM t_proxy tp start with tp.id in (select distinct tm.proxy_id from t_merchant tm where tm.proxy_id is not null) connect by prior tp.parent_id = tp.id)…
create or replace function fn_DeptWholeName2(objectid in number) return nvarchar2 is wholename nvarchar2(500); beginselect to_char(replace(wm_concat(OBJNAME),',','.'))a into wholename from (select * from v_organddept2 ostart with o.objid=objectidconn…