title: Rank query using row_number reversed
body: <p>I have a query where I am ranking the returned rows (<a href="https://stackoverflow.com/questions/25732309/generating-a-ordered-sequence-rank-on-complex-query">related question</a>). What I would like to be able to do is reverse the rank, and set the new_rank accordingly. Lets assume I have <code>999</code> entries.</p>
  
  <p>For instance if I have this query:</p>
  
  <pre><code>with persondata as (
     SELECT firstname,
            lastname,
            year,
            personid,
          ((SELECT COALESCE(SUM(thevalue),0)
            FROM assets
            WHERE personidref = w.personid AND year = w.year)
         - (SELECT COALESCE(SUM(amount),0)
            FROM liabilities
            WHERE personidref = w.personid AND year = w.year)) as worth,
            row_number() over(ORDER BY w.worth DESC) as new_rank,
           visible
     FROM members w 
     WHERE year = 2014 
     AND visible = 1 
     ORDER BY worth ASC LIMIT 5
  ) 
  select row_number() over (order by worth DESC) as rank,
         * 
  from persondata
  </code></pre>
  
  <p>This rightly returns the bottom 5 in the desired order see below:</p>
  
  <pre><code> rank | firstname |     lastname      |  worth   | new_rank
  ------+-----------+-------------------+----------+----------
      1 | Peter     | Griffin           |  -520000 |      145 
      2 | Steve     | Moffat            |  -530000 |      519 
      3 | Gregory   | Peck              |  -540000 |      131 
      4 | Ruben     | Mumbles           |  -550000 |      130 
      5 | Ricky     | Swiss             |  -560000 |      120
  </code></pre>
  
  <p>Is there a way to incorporate the <code>row_count</code> and subtract current row count? Or set a counter to be used temporarily, that is set to row count then decrement?</p>
  
  <p>Final desired result:</p>
  
  <pre><code> rank | firstname |     lastname      |  worth   | new_rank 
  ------+-----------+-------------------+----------+----------
    997 | Peter     | Griffin           |  -520000 |      145 
    996 | Steve     | Moffat            |  -530000 |      519 
    997 | Gregory   | Peck              |  -540000 |      131 
    998 | Ruben     | Mumbles           |  -550000 |      130 
    999 | Ricky     | Swiss             |  -560000 |      120 
  </code></pre>
  
  <p>I haven't been able to find anything regarding this implementation on using <code>row_number</code>.</p>