title: Does `sqlite3` support loops?
body: <p>I wrote the little bash script below and it works as intended, but I added couple comments and newlines for readability which breaks the code. Removing comments and newlines should make it a valid script.</p>
  
  <pre><code>### read all measurements from the database and list each value only once
  sqlite3 -init /tmp/timeout /tmp/testje.sqlite \
    'select distinct measurement from errors order by measurement;' |
  
  ### remove the first line of stdout as this is a notification rather than intended output
  sed '1d' |
  
  ### loop though all found values
  while read error; do 
  
    ### count the number of occurences in the original table and print that
    sqlite3 -init /tmp/timeout /tmp/testje.sqlite \
      "select $error,count( measurement ) from errors where measurement = '$error' ;"
  done
  </code></pre>
  
  <p>The result is like this:</p>
  
  <pre><code>134         1                   
  136         1                   
  139         2                   
  159         1
  </code></pre>
  
  <p><strong>Question:</strong> Is it possible with <code>sqlite3</code> to translate the <code>while</code>-loop to SQL statements? In other words, does sqlite3 support some sort of <code>for</code>-loop to loop through results of a previous query?</p>
  
  <p>Now I know <code>sqlite3</code> is a very limited database and chances are that what I want is just too complex for it. I've been searching, for it but I'm really a database nitwit and the hits I get so far are either on a different database or solving an entirely different problem. </p>
  
  <p>The easiest answer (that I do not hope for BTW) is 'sqlite3 does not support loops'.</p>