title: Pass Variable from View in LIMIT clause in Bigquery
body: <p>I need to create a variable which will store the number of users to be filtered. Basically, I need to check how many events a user generates within a certain number of months and then only the top number of users are used. 
  I noticed that Bigquery does not have a set variable functionality, therefore I created a view which has my variables. </p>
  
  <p>I have the following Bigquery SQL code.</p>
  
  <pre><code>WITH vars AS (
    SELECT 3 as num_months,
           200000 as num_users
  )
  
  SELECT id, count(d.value) as count_value
  FROM events_data evt, unnest(evt.data) AS d, vars
  WHERE  DATE(eventdate) &gt; date_sub(current_date(), INTERVAL num_months MONTH) AND d.key='eventid'
  GROUP BY id
  ORDER BY count_value
  LIMIT num_users
  </code></pre>
  
  <p>The use of <code>num_months</code> works perfectly within the filtering of the number months however when I try to limit the number of users within the <code>LIMIT</code> clause it gives the following error </p>
  
  <pre><code>Syntax error: Unexpected identifier "num_users"
  </code></pre>
  
  <p>I have even tried referencing the view as well like <code>vars.num_users</code></p>