You cannot make this view indexed.
Basically, here you have a summary function (disguised as CROSS APPLY ).
The only aggregate functions allowed in the indexed view are COUNT_BIG and SUM , because they are distributed by addition and subtraction of the set, i.e. SUM(a UNION ALL b) = SUM(a) + SUM(b) , SUM(a EXCEPT ALL b) = SUM(a) - SUM(b) .
This property is required for the index to be supported.
When a new record is inserted, updated, or deleted from the base table, the entire review does not need to be overestimated: the value of the new record is simply added or subtracted from the cumulative value.
In addition, a COUNT_BIG must also be part of the view in order to track the deletion of records (when it becomes 0 , the record must be deleted from the view index).
source share