select distinct sel.empty_tu_loc_id, sel.loc_id from
(
SELECT CONNECT_BY_ROOT LOC_ID_PARENT AS empty_tu_loc_id, LN.LOC_ID AS loc_id
FROM LN_LOC_LOC LN
CONNECT BY PRIOR LOC_ID = LOC_ID_PARENT and link_type = 'PARENT'
START WITH LOC_ID_PARENT IN (SELECT e.loc_id FROM empty_tu_loc e inner join grp g on g.loc_id= e.loc_id)
) sel
left outer join empty_tu_loc e1 on e1.loc_id=sel.loc_id
where e1.loc_id is null
union all
SELECT distinct loc_id, loc_id FROM empty_tu_loc
);
我很困惑:
如何将此代码迁移到ms sql-sever 2014?
答案 0 :(得分:0)