title: How do I store my 'view' as a permanent table in mySQL?
body: <p>I'm new to SQL and still learning. </p>
  
  <p>Once I've done operations on a table (say table 1) to get a view. How do I translate/convert/store this view into a new permanent table (table 2)? Also, is it possible to store it in the same table (table 1)?</p>
  
  <p>My code is something like this: </p>
  
  <pre><code>select `Date`, `Close Price`,
  round(avg(`Close Price`) over (order by `date` asc rows 19 preceding), 2) 
  as '20 Day MA' 
  from table1;  -- this is my view
  </code></pre>
  
  <p>then i'd like table1 or a new table to store this view (the columns 
   <strong>date, close price, 20 day ma</strong>)</p>
  
  <p><strong>basically,</strong><br>
  Old table: date, close price </p>
  
  <p>New table: date, close price, 20_day_ma</p>
  
  <p>Maybe it's simpler to just add the new column <strong>20_day_ma</strong> but I wouldn't know how to add the new values that rely on the other columns. </p>
  
  <p><strong>edit:</strong></p>
  
  <p>So just tried this:</p>
  
  <pre><code>DELIMITER $$
  -- create table1
  drop table if exists table1;
  
  create table table1 as
  select STR_TO_DATE(`Date`, '%d-%M-%Y') as `Date`, `Close Price`,
  round(avg(`Close Price`) over (order by `date` asc rows 19 preceding), 2) as 
  '20 Day MA'
  from source_table $$
  
  DELIMITER ;
  </code></pre>
  
  <p>And I constantly get the error: <em>Commands out of sync</em></p>