using rank() and window functions in Greenplum