title: Cannot create a CLUSTERED INDEX on a View because I'm referencing the same table twice, any workaround?
body: <p>I want to create an indexed view that integrates data from several tables, however SQL Server complains with the error message: </p>
  
  <p><em>Cannot create index on view "MyView". The view contains a self join on "dbo.Companies".</em></p>
  
  <p>The view definition is something like this (simplified version):</p>
  
  <pre><code>SELECT  T.Field1
        , T.Field2
        , P.CompanyName AS ProviderName
        , C.CompanyName AS CustomerName
        , T3.Field1
  FROM dbo.Table1 T 
                    INNER JOIN dbo.Companies P ON T.ProviderId = T2.Id
                    INNER JOIN dbo.Companies C ON T.CustomerId = T2.Id
                    INNER JOIN dbo.Table3 ON T.Id = T3.Id
  </code></pre>
  
  <p>Is there any workaround for this case? I don't want to split the <em>Companies</em> table in two tables.</p>
  
  <p>Thanks in advance.</p>