title: I want row number in view Or variable in View
body: <p>I know it is not possible directly.
  But I want to achieve this by any indirect method if possible.</p>
  
  <p>Actually I wanted to add below query to view which throws error , Sub query not allowed in view.</p>
  
  <pre><code>select T1.Code,
         T1.month,
         T1.value,
         IfNull(T2.Value,0)+IfNull(T3.value,0) as value_begin
  
    from (select *,@rownum := @rownum + 1 as rownum
            from Table1 
            Join (SELECT @rownum := 0) r) T1
    left join (select *,@rownum1 := @rownum1 + 1 as rownum
                 from Table1 
                 Join (SELECT @rownum1 := 0) r) T2
      on T1.code = T2.code
     and T1.rownum = T2.rownum + 1
    left join (select *,@rownum2 := @rownum2 + 1 as rownum
                 from Table1 
                 Join (SELECT @rownum2 := 0) r) T3
      on T1.code = T3.code
     and T1.rownum = T3.rownum + 2
   Order by T1.Code,T1.rownum
  </code></pre>
  
  <p>So, I thought I will make Sub query as separate view but that again throws error that variables not allowed in view. Please Help to overcome this situation.</p>
  
  <p>Thanx in advance</p>