title: select one row's id in case of multiple max values in sql
body: <p>I want to select only the id which has the maximum precedence with the following table (table1) whose item_id is 1001.</p>
  
  <p>table1</p>
  
  <pre><code>id  | plan_id | item_id | plan_item_bundle_id | precedence 
  -----+---------+---------+---------------------+------------
  
   401 |         |    1001 |                     |         -1
  
   402 |         |    1001 |                     |         -1
  </code></pre>
  
  <p>How can I do it ? Thanks</p>
  
  <p>I dont care if the precedence is same, any one would do. 
  Thanks</p>