SQL Server 2008 R2 and know that in
Indexed View cant have self join.
I have a tree table that have
ParentID Column and I need create indexed view on this table with self join between each record and parent record. can I simulate self join in this view?
My table structure is :
SAM.Detail (DetailID Int, ParentDetailID Int, Quantity Int, ...)
and my query is :
Select A.DetailID, A.Quantity - SUM(B.Quantity) as RemainQuantity, COUNT_BIG(*) as CountBig From SAM.Detail A inner join SAM.Detail B ON B.ParentDetailID = A.DetailID Group By A.DetailID, A.Quantity