i want find possible combinations of userid-chain following subset example:

the result of example must produce 4 different chain of userid:
- 32,34,36...39
- 32,35,36...39
- 33,34,36...39
- 33,35,36...39
all can displayed in vertical result table (following first example)

in original table have data different userid/companyid need recursive solution different iteration of currentlevel users
;with cte ( select companyid, currentlevel, userid @result currentlevel = 1 union select rec.companyid, rec.currentlevel, rec.userid @result r inner join cte rec on rec.companyid = r.companyid , rec.currentlevel = r.currentlevel +1 ) then select
select * cte but not found solutions that.
Comments
Post a Comment