title: How to use rank to get the latest bonus record
body: <p>currently I am using the below query to get the previous year’s bonus amount for the employees. But I am facing some issues, so I am trying to get the latest element entry value(screen entry value) for the element ‘xyz bonus’ using the RANK() function. Please help. Thanks.</p>
  
  <pre><code>Select 
  Pam.assignment_number,
  Peev.screen_entry_value as bonus_amount
  From
  Per_all_assignments_m Pam,
  Pay_element_entries_f peef,
  Pay_element_types_tl petl,
  Pay_element_entry_values_f peev
  Where
  Pam.Person_id=peef.person_id
  and peef.element_type_id = petl. element_type_id
  And peef.element_entry_id = peev. element_entry_id
  And petl.language=‘US’
  And to_char(peef.effective_start_date,’yyyy’)=(to_char(sysdate,’yyyy’)-1)
  And to_char(peev.effective_start_date,’yyyy’)=(to_char(sysdate,’yyyy’)-1)
  And petl.element_name = ‘xyz bonus’
  </code></pre>