title: Shell scripting SQLite
body: <p>How do I write a shell script that displays SQLite results? I have written a script that adds an entry to the SQLite database. Now I want to display the results after adding that entry.
  Here's my script:</p>
  
  <pre><code>echo 'insert into myTable (Date, Details, Category, Average) values (datetime('\''now'\'','\''localtime'\''), '\'''$1''\'', '\'''$2''\'', '$3');'|sqlite3 /Users/user/Documents/Test/dbName.db
  </code></pre>
  
  <p>After this I want the script to echo/spit the output of statements:</p>
  
  <pre><code>select sum(Average) from (select * from myTable where Category = 'category1');
  select sum(Average) from (select * from myTable where Category = 'category2');
  </code></pre>
  
  <p>The format should be like this:</p>
  
  <pre><code>Category1 total = &lt;output of first statement&gt;
  Category2 total = &lt;output of second statement&gt;
  </code></pre>
  
  <p>Thats it. I am quite new to SQL and not that great with shell scripting. I am also looking for good tutorials explaining problems like this.</p>