title: Max Query Sybase
body: <p>I have table "content":</p>
  
  <pre><code>content_id , relative_sortorder
  1          1
  2          1
  3          2
  4          3
  **5          4**
  6          1
  7          2
  8          ...
  9          100
  </code></pre>
  
  <p>I want to do a query that returns the previous content_id by selecting the max(relative_sortorder) and that needs to be lower than the current relative_sortorder.</p>
  
  <p>I don't have any idea, please help :)</p>
  
  <p>This return only the max -</p>
  
  <p>SELECT  max(c.relative_sortorder)
  FROM   "DBA"."CONTENT" c
  WHERE  c.relative_sortorder &lt; 4 and content_id &lt; 5</p>
  
  <p>But I need the previous row
  <img src="https://i.stack.imgur.com/MXLBh.png" alt="enter image description here"></p>
  
  <p>Alright, so i have these results, I want to filter them to show only the one with the maximum relative_sortorder, in this case second row. I dont know how to create the subquery</p>