clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1451527 fiddles created (18771 in the last week).

CREATE TABLE [dependence]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [nvarchar](255) NULL, [task_uid] [int] NULL, [link_pred_uid] [int] NULL, [link_uid] [int] NULL, [link_succ_uid] [int] NULL); INSERT INTO [dependence] ([name],[task_uid],[link_pred_uid],[link_uid],[link_succ_uid]) VALUES ('task 1',10,4,2,2), ('task 2',11,6,4,2), ('task 3',12,6,6,4), ('task 4',13,10,8,8), ('task 5',14,10,10,8); SELECT * FROM dependence; WITH cte AS ( SELECT *, CAST(link_uid AS VARCHAR(64)) path FROM dependence WHERE link_uid = link_succ_uid UNION ALL SELECT dependence.*, CAST(CONCAT(cte.path, '/', dependence.link_uid) AS VARCHAR(64)) FROM dependence JOIN cte ON cte.link_pred_uid = dependence.link_uid WHERE cte.link_pred_uid != cte.link_uid ) SELECT * FROM cte;
id name task_uid link_pred_uid link_uid link_succ_uid
1 task 1 10 4 2 2
2 task 2 11 6 4 2
3 task 3 12 6 6 4
4 task 4 13 10 8 8
5 task 5 14 10 10 8
id name task_uid link_pred_uid link_uid link_succ_uid path
1 task 1 10 4 2 2 2
4 task 4 13 10 8 8 8
5 task 5 14 10 10 8 8/10
2 task 2 11 6 4 2 2/4
3 task 3 12 6 6 4 2/4/6
 hidden batch(es)