title: Is it possible to use a variable or parameter in a MySQL view?
body: <p>I'm trying to create a View as following:</p>
  
  <pre><code>CREATE VIEW v_MyView
  AS
  
  SET @par_count := 0;  -- XXX Working in SELECT, but not in a View !? XXX
  
  SELECT
      q1.day,
      q1.count_per_day,
      (@par_count := @par_count  + q1.count_per_day) AS count_sum  -- sums up count_per_day 
  FROM
      (SELECT
          DATE(registration_date_time_obj) AS day,
          COUNT(Date(registration_date_time_obj)) AS count_per_day
       FROM  tbl_registration_data
       GROUP BY day
       ORDER BY day
      ) AS q1
  ;
  </code></pre>
  
  <p>The select statement itself works fine, just creating a view fails in MySQL since it doesn't accept user variables/parameters within it's declaration i guess. </p>
  
  <p><strong>Is there a way to still create this view with a workaround for the parameter?</strong> </p>
  
  <p>Anyways, i'm able to create a similar procedure for the select statement, but that doesn't really solve the problem since i can't call the procedure in another select statement... </p>
  
  <p>Thanks for your suggestions and solutions!  (:</p>