title: How to use max and group by statement on my SQL query?
body: <pre><code>task_name         start_time            value
  acc_clock         2010-05-27              4
  icc_opy           2010-05-28              5
  icc_dtaf          2010-05-29              3
  acc_clock         2010-05-25             34
  icc_ruty          2010-05-23             33
  icc_ruty          2010-05-22             45
  </code></pre>
  
  <p>This is my output of a SQL query which is coming from two different tables. Note that in this output, <code>task_name</code> is occuring twice. Now I want the output to have only one occurence of <code>task_name</code> and its associated value should be the maximum <code>start_time</code>, like this:</p>
  
  <pre><code>task_name         start_time            value
  icc_opy           2010-05-28              5
  icc_dtaf          2010-05-29              3
  acc_clock         2010-05-25             34
  icc_ruty          2010-05-23             33
  </code></pre>
  
  <p>My query is </p>
  
  <pre><code>select t.task_name, 
              max(t.start_time) , 
              i.value
  from    task_runs t,
              integer_values i 
  where i.run_id= t.id 
      and t.username= 'amit' 
      and t.start_time &gt; '2010-05-20' 
  order by t.task_name 
   group by t.task_name?????????       
  </code></pre>
  
  <hr>
  
  <p>Why my query is not working?</p>
  
  <p>My values coming from two tables : task_runs, integer_value. I want these three columns but task name with max start_time with associated its value.</p>