title: SQLite impute missing values by mean for every group
body: <p>I have an SQLite table as shown below.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>students</th>
  <th>grades</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Nick</td>
  <td>34</td>
  </tr>
  <tr>
  <td>Nick</td>
  <td>42</td>
  </tr>
  <tr>
  <td>Nick</td>
  <td>86</td>
  </tr>
  <tr>
  <td>Nick</td>
  <td>Null</td>
  </tr>
  <tr>
  <td>John</td>
  <td>38</td>
  </tr>
  <tr>
  <td>John</td>
  <td>12</td>
  </tr>
  <tr>
  <td>John</td>
  <td>74</td>
  </tr>
  <tr>
  <td>John</td>
  <td>Null</td>
  </tr>
  <tr>
  <td>Colin</td>
  <td>87</td>
  </tr>
  <tr>
  <td>Colin</td>
  <td>23</td>
  </tr>
  <tr>
  <td>Colin</td>
  <td>46</td>
  </tr>
  <tr>
  <td>Colin</td>
  <td>42</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I want to do is impute Null values with the mean of each student's grades.
  For example, missing value for Nick will be 54 and for John 41.3.
  How can I do this in SQL code? I am using SQLite.</p>