title: Using max function
body: <p>I have two tables:</p>
  
  <pre><code>TotalTimeTable
  (date date,time time)
  
  FinalListA
  (date date, time time, A int, B int)
  </code></pre>
  
  <p>I am running the following query:</p>
  
  <pre><code>SELECT t1.date,
         t1.time,
         max(t2.time)
  FROM TotalTimeTable t1,
       FinalListA t2
  WHERE t2.date=t1.date
    AND t2.time &lt;= t1.time
  GROUP BY t1.date,
           t1.time
  ORDER BY t1.date,
           t1.time
  </code></pre>
  
  <p>Is there a way to pull out A and B from FinalListA where time = "max(t2.time)" in the same query?</p>
  
  <p>TotalTimeTable:</p>
  
  <pre><code>date        time    
  2006-01-01  9:30:01     
  2006-01-01  9:30:02 
  2006-01-01  9:30:03
  2006-01-01  9:30:04
  2006-01-01  9:30:05 
  2006-01-01  9:30:06
  </code></pre>
  
  <p>FinalListA:</p>
  
  <pre><code>date        time     A B
  2006-01-01  9:28:01  1 4
  2006-01-01  9:30:02  2 3
  2006-01-01  9:30:04  4 7
  2006-01-01  9:30:07  6 4
  2006-01-01  9:30:10  8 9
  2006-01-01  9:30:11  1 2
  </code></pre>
  
  <p>The expected result is:</p>
  
  <pre><code>date        time     A B
  2006-01-01  9:30:01  1 4
  2006-01-01  9:30:02  2 3
  2006-01-01  9:30:03  2 3
  2006-01-01  9:30:04  4 7
  2006-01-01  9:30:05  4 7
  2006-01-01  9:30:06  4 7
  </code></pre>
  
  <p>The time is from TotalTimeTable
  FinalListA.time don't have to be in the result.</p>