title: sqlite Common table expression
body: <p>I was working at a project and I've been asked to rewrite this subquerie</p>
  <pre><code>SELECT c.last_name, c.first_name, i.total_avg
    FROM customer AS c
    JOIN (SELECT customer_id, AVG(total) AS total_avg
            FROM invoice
           GROUP BY customer_id) AS i
      ON c.customer_id = i.customer_id;
  </code></pre>
  <p>using CTE.</p>
  <p>I don't know how to link the two tables.</p>
  <p>Could you help me?
  Thank you very much!!!</p>