I have a task to roll up a test sample.
I have the script to set the parent ID, but the crating the results I am stuck on. Can anyone give pointers or help?
This is how I set the parent ID
SELECT C.aid as ID,c.aage as age, min(D.parentid) as parentid
FROM Scott_Work.dbo.Test2 as D
--This section pulls of the linked ID's into a group(C) based on what matched (parentid)
(SELECT A.ID as aid, B.ID as bid,a.age as aage FROM Scott_Work.dbo.Test2 as A JOIN Scott_Work.dbo.Test2 as B ON A.parentid = B.parentid) AS C
ON C.bid = D.ID
group by C.aid,c.aage order by 1