title: Fetch 3 latest details from table
body: <p>I want to fetch 3 latest devices for a person. Table structure is shown below</p>
  
  <pre><code>PERSON_DEVICE
  
  person_id  seq_num   device_detail device_detail_added
  999         1           Nexus        03/04/2015
  999         2            iphone       06/07/2015
  999         3            laptop       08/09/2015
  999         4            uda           02/01/2016
  999         5            pda            04/04/2016
  1001        1            sm             03/03/2015 
  ... and so on
  </code></pre>
  
  <p>For latest device for a person I can use  following query</p>
  
  <pre><code>select * from PERSON_DEVICE
  where person_id = 999
    and seq_num = (select max(seq_num) from PERSON_DEVICE where person_id = 999)
  </code></pre>
  
  <p>but for second latest and third latest, I don`t know how to get this ?</p>
  
  <p>I tried using <code>limit</code>, but in Sybase  it is not working (for my Sybase version).</p>
  
  <p>P.S. seq_num is used to identify latest device for a particular person id.</p>
  
  <p>********************EDIT*****************************************88</p>
  
  <pre><code> PERSON 
  person_id  name   addres
  999         john   2 avenue
  1001      elliot    rrt
  
  I want to  records to 
  
  select   pn.name , pd.device1 ,pd.device_detail_added1, pd.device2 ,pd.device_detail_added2,pd.device3 ,pd.device_detail_added3 from  PERSON pn , PERSON_DEVICE pd
  </code></pre>