title: SQL query on a pair of fields together
body: <p>I have a table like this:</p>
  
  <pre><code>name | action      |    action_timestamp
  ------------------------------------------
  ABC  | START_PLAY  |  2017-02-02 10:00:00
  PQR  | START_PLAY  |  2017-02-02 11:00:00
  ABC  | END_PLAY    |  2017-02-02 10:30:00
  PQR  | END_PLAY    |  2017-02-02 11:05:00  
  </code></pre>
  
  <p>I want to get all the names who have started playing on or after a given timestamp and ended play on or before a given timestamp.</p>
  
  <p>For example, if (action='START_PLAY' and action_timestamp >= 2017-02-02 10:00:00 ) and (action='END_PLAY' and action_timestamp &lt;=2017-02-02 10:30:00) then the query should return me ABC</p>
  
  <p>I am not sure how should I make the conditions (viz. start_play and action_timestamp) as one.</p>