And: pref=> select * from ( select u.id, u.first_name, u.city, m.money, rank() over (order by money desc) from pref_users u, pref_money m where m.yw=to_char(current_timestamp, 'YYYY-IW') ) ar where ar.id='OK138239987797'; works, but delivers 800 different ranks: id | first_name | city | money | rank ----------------+------------+-------------+-------+--------- OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 2169 | 1 OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 1955 | 3479 OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 1948 | 6957 OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 1060 | 10435 OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 1034 | 13913 OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 1012 | 17391 OK138239987797 | ÐÐÐÐ | ÐÐÐÐÑÐÐÐÑÑÐ | 929 | 20869 -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general