We have a huge table with millions of records. We want to fetch only first record based on some key in that table. When I tried using self-join it's resulting in temp db space issue. From the performance point of view, I was thinking of using an indexed view. But I can't use left join or CTE in an indexed view.
Is there any way available to fetch only non duplicate records using indexed views?
The scenario is that an indexed view contains distinct values of the "key" that are joined to the first row on the source table.
Prepare example data
Create indexed view
The query
Result