title: Split-apply-combine in SQLite
body: <p>Is there an SQLite equivalent of <code>by</code> or the split-apply-combine strategy?</p>
  
  <p>Specifically, I have a table with columns <code>firm,flag</code>. <code>firm</code> is an integer that takes on a few hundred values (a firm id), <code>flag</code> is an integer taking on the values {0,1}.  There are hundreds of entries per firm.  I would like to compute the mean of flag for each firm, then store that in the same table (not efficient, I know, as each value will be repeated multiple times).</p>