title: Second maximum value by using dense rank function
body: <p>I have table like:</p>
  
  <pre><code>name     marks
  raja     88
  ravi     88
  karthik  99
  praveen  99
  vijay    70
  </code></pre>
  
  <p>In that table I assume the rank of the table is:</p>
  
  <pre><code>name      marks        rank 
  karthirk    99           1
  praveen     99           2
  raja        88           3
  ravi        88           4
  vijay       77           5
  </code></pre>
  
  <p>I get that by using <code>dense rank()</code> function: </p>
  
  <pre><code>select  name,marks,dense_rank() over(  order by name ) as ranks
  from std_D_D order by marks desc
  </code></pre>
  
  <p>but what I need is from that above table I need to get second lowest rank. 
  I mean the output  I want is:</p>
  
  <pre><code>ravi 88   4
  </code></pre>
  
  <p>I tried to get the second lowest rank but I can't get the all the columns. I tried this query:</p>
  
  <pre><code>select max(a.ranks) as b from (
  select  name,marks,dense_rank() over(  order by name ) as ranks
  from std_D_D ) as a where a.ranks not in
  (
  
  select max(a.ranks) as b from (
  select  name,marks,dense_rank() over(  order by name ) as ranks
  from std_D_D ) as a )
  </code></pre>