title: Why do partitions require nested selects?
body: <p>I have a page to show 10 messages by each user (don't ask me why)<br>
  I have the following code:</p>
  
  <p><code>
  SELECT *, row_number() over(partition by user_id) as row_num<br>
  FROM "posts"<br>
  WHERE row_num &lt;= 10<br>
  </code>    </p>
  
  <p>It doesn't work.</p>
  
  <p>When I do this:<br>
  <code>
  SELECT *<br>
  FROM (<br>
    SELECT *, row_number() over(partition by user_id) as row_num FROM "posts") as T<br>
  WHERE row_num &lt;= 10<br>
  </code></p>
  
  <p>It does work.<br>
  Why do I need nested query to see <code>row_num</code> column? Btw, in first request I actually see it in results but can't use <code>where</code> keyword for this column.</p>