title: SQLite: Select column based on calculation or name
body: <p>I'm a SQL beginner. I have two SQLite tables: one with information about work times and one with time budget per weekday for specific time ranges. I wonder how I can select the correct budget for the day for any of the work time enterys.</p>
  
  <pre class="lang-none prettyprint-override"><code>Work_Times
  +---------------------+---------------------+--------+
  |        begin        |         end         | Note   |
  +---------------------+---------------------+--------+
  | 2011-08-02 00:00:00 | 2013-08-02 00:00:00 | Free   |
  | 2011-10-15 06:00:00 | 2011-10-15 09:45:00 | Tour A |
  | 2011-12-05 05:30:00 | 2011-03-05 10:00:00 | Tour B |
  +---------------------+---------------------+--------+
  
  Week_Budget
  +------------+------------+------+------+------+------+------+------+------+-------+
  | from       | to         | Mon  | Tue  | Wed  | Thu  | Fri  | Sat  | Sun  | sum   |
  +------------+------------+------+------+------+------+------+------+------+-------+
  | 01.08.2011 | 30.09.2011 | 3.80 | 3.80 | 3.85 | 3.80 | 0.00 | 0.00 | 0.00 | 15.25 |
  | 01.10.2011 | 27.11.2011 | 4.18 | 4.18 | 4.25 | 4.18 | 0.00 | 0.00 | 0.00 | 16.79 |
  | 28.11.2011 | 31.03.2012 | 3.25 | 3.25 | 3.25 | 3.25 | 3.00 | 0.00 | 0.00 | 16.00 |
  +------------+------------+------+------+------+------+------+------+------+-------+
  </code></pre>
  
  <p>I think I can join the rows with …</p>
  
  <p>WHERE Week_Buget.from => Work_Times.begin &lt;= Week_Buget.to</p>
  
  <p>… but I can't find a way to select the right column depenting on maybe the daynumber (%w).</p>