• hi,

    the syntax error might be cause of table is not exists please create table which is commented,

    Logic: in first cte I find out the chain depends upon the col1.

    and cte2 i tried to find maximum chain which is exist against col1.

    Regards,
    Mitesh OSwal
    +918698619998