File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change 1- SELECT levels
2- , PersonId
3- , Friends
4- FROM (SELECT Person1 .personId AS PersonId
5- , STRING_AGG(Person2 .personId , ' ;' ) WITHIN GROUP (GRAPH PATH ) AS Friends
6- , LAST_VALUE(Person2 .personId ) WITHIN GROUP (GRAPH PATH ) AS LastNode
7- , COUNT (Person2 .personId ) WITHIN GROUP (GRAPH PATH ) AS levels
8- FROM Person AS Person1
9- , Person_knows_Person FOR PATH AS fo
10- , Person FOR PATH AS Person2
11- WHERE MATCH(SHORTEST_PATH(Person1(- (fo)- > Person2)+ ))
12- AND Person1 .personId = :person1Id
13- ) AS Q
14- WHERE Q .LastNode = :person2Id
1+ DECLARE @trustedPaths as table
2+ (
3+ Id bigint ,
4+ OrderDiscovered int ,
5+ Path varchar (MAX )
6+ )
7+
8+ INSERT INTO @trustedPaths
9+ EXEC dbo .knows_Breadth_First :person1Id, :person2Id;
10+
11+ SELECT TOP (1 ) OrderDiscovered, Id, Path
12+ FROM @trustedPaths
13+ ORDER BY OrderDiscovered ASC ;
You can’t perform that action at this time.
0 commit comments