title: SR0004 - A column without an index that is used as IN predicate test expression might degrade performance
body: <p>I'm quite new to SQL so I have received the error as stated in my question title. </p>
  
  <p>The attached image is my sql command.
  <img src="https://i.stack.imgur.com/LETxk.png" alt="enter image description here"></p>
  
  <p>If I do not use IN, 
  I will get another error which is subquery returns more than 1 value...</p>
  
  <p>How should I write it so that I would not get any of these error?</p>
  
  <p>Below is the SQLcode:
  BEGIN</p>
  
  <pre><code>   SELECT [c].[ChargeSubCategoryOID] ,[c].[Description], [c].[Qty], [c].[Uom], [c].[BeforeGovtSubsidy], [c].[AfterGovtSubsidy],
  
     [c].[ChargesIndicatorCode], [c].[ChargesIndicatorValue]
  
     FROM ChargeItems AS [c]
  
     WHERE
  
     [c].[ChargeSubCategoryOID] IN
  
     (
  
            SELECT [c].[OID]
  
            FROM ChargeSubCategories AS [c]
  
            WHERE
  
            [c].[ChargeCategoryOID] IN
  
            (
  
                   SELECT [cg].[OID]
  
                   FROM ChargeCategories AS [cg]
  
                   WHERE
  
                   [cg].[ChargeGroupOID] IN
  
                   (
  
                         SELECT [cg].[OID]
  
                         FROM ChargeGroups AS [cg]
  
                         WHERE
  
                         [cg].[InvoiceOID] IN
  
                         (
  
                                SELECT TOP(1)
  
                                [p].[OID]
  
                                FROM [Invoices] AS [p]
  
                                LEFT JOIN [Payors] AS [p.Payors] ON [p].[OID] = [p.Payors].[InvoiceOID]
  
                                LEFT JOIN [Details] AS [p.Details] ON [p].[OID] = [p.Details].[InvoiceOID]
  
                                WHERE ([p].[InvoiceReferenceNo] = @BillRefNo) AND ([p.Details].[IdentificationNoValue] = @Id)
  
                                ORDER BY [p].[CreationTime] DESC, [p].[OID], [p.Payors].[OID]       
  
                         )            
  
                   )     
  
     )
  
     )ORDER BY [c].[ChargeSubCategoryOID] ASC
  </code></pre>
  
  <p>END</p>
  
  <p>Any help is appreciated! Thanks!</p>