title: the select item identified by the order by number_1 contains a variable as a part of the expression identifying a column position
body: <pre><code>CREATE PROCEDURE [dbo].[sp_Alx_GetCurrespondentSubledger] -- '01-Jan-2016',NULL
      @FromDate datetime,
      @ToDate datetime,
      @CorrespondetID bigint = -1,
      @CorrespondentAccountID bigint = -1,
      @TransactionTypeID bigint = -1,
      @TrxnCurrencyID bigint = -1,
      @PageNo int = 0,
      @NumberOfRecords int = 20
  AS
  BEGIN
      set nocount on
  
      declare
          @StartNo bigint = 0,
          @EndNo bigint = 0,
          @TotalRecords bigint = 0
  
      SET @StartNo = @PageNo * @NumberOfRecords;
  
      select     
          L.TrxnDate, L.TrxnCode,
          p.ProductCode, L.TrxnCurrencyQty, L.TrxnCurrencyRate, L.TTExpence, 
          L.LocalCurrncyRecvQty AS Debit,
          L.LocalCurrncyIssQty As Credit
      from 
          [dbo].[ALX_CurrespondentWACostLedger] as L
      left outer join 
          ALX_Products P on L.TrxnCurrencyID = P.ProductID
      where
          L.TrxnDate BETWEEN ISNULL(@FromDate, Convert(date,getDate())) AND ISNULL(@ToDate,GetDate())
  AND ((@CorrespondetID&gt;0 AND L.CorrespondentID=@CorrespondetID) OR @CorrespondetID&lt;=0)
  AND((@CorrespondentAccountID&gt;0 AND L.CorrespondentAccountID=@CorrespondentAccountID)OR @CorrespondentAccountID&lt;=0)
  AND((@TransactionTypeID&gt;0AND L.TransactionTypeID=@TransactionTypeID)OR @TransactionTypeID&lt;=0)
  AND((@TrxnCurrencyID&gt;0AND L.TrxnCurrencyID=@TrxnCurrencyID)or @TrxnCurrencyID&lt;=0)
  ORDER BY @TransactionTypeID
  OFFSET @StartNo ROWS
  FETCH NEXT @NumberOfRecords ROWS ONLY
  end
  </code></pre>