How to use Oracle ORDER BY and ROWNUM correctly?

I am having a hard time converting stored procedures from SQL Server to Oracle to have our product compatible with it. I have queries which returns the most recent record of some tables, based on a