Запрос, составляющий транзитивное замыкание ациклического ориентированного графа
WITH TC AS ( BEGIN CALLOUT A SELECT src_pid, tgt_pid FROM Links END CALLOUT A UNION ALL BEGIN CALLOUT B SELECT P.src_pid, C.tgt_pid FROM Links AS C JOIN TC AS P ON C.src_pid = P.tgt_pid END CALLOUT B ) SELECT DISTINCT * FROM TC ORDER BY src_pid, tgt_pid;