Perhaps you want to find the 5 most sold items for every month of the year or you need to figure out who worked the longest hours from a timesheet system. The rank query returns a sequence over the "top ranked" rows as ordered by the rank queried. If you just want the top 1 you just select the whole rank statement as an identifier and add "where identifier=1" in your outer where statement.
I wrote this mockup query to show how it can be used.
We have a nice web based application where we, for audit purposes, store all applications logins to a logins table in the database. Lets say that you for some unknown reason need to figure out who was the first user to login each month (yes I know, terrible use case).
to_char(time,'YYYY-MM-DD HH24:MI:SS') LOGON_TIME
rank() over(partition by user_id
order by time asc) rowrank
68 2006-02-01 00:07:04
68 2006-03-01 00:07:17
68 2006-04-01 03:21:17
108 2006-05-01 00:00:13
Im working on the second part of the XML stuff.