title: SQL statement to get the MIN() from the AVG() returned from second query
body: <p>I got a question regarding subquery in SQL statement. What I am trying to do is to find a minimum time with the average column result returned from another query.</p>
  
  <pre><code>SELECT userID
  FROM myTable
  WHERE time = MIN(...)
  
  SELECT userID, AVG(date_time)
  FROM myTable
  GROUP BY userID
  </code></pre>
  
  <p>The second query will return me the average between two times and group by a third party.</p>
  
  <p>Then my first query need to find the minimum average time return from my second query. How can I combine both of the queries together?</p>
  
  <p>The sample data for my second query is like:</p>
  
  <pre><code>user1  20
  user2  45
  user3  10
  </code></pre>
  
  <p>Then for my first query, I need to get the user with minimum average:</p>
  
  <pre><code>user3  10
  </code></pre>
  
  <p>Thanks in advance.</p>