title: How to get group number in postgresql?
body: <p>I have a use case where I want to assign a unique increasing partition number to each partition when using a window query in postgres.</p>
  
  <p>For example, I want to get an output like this: </p>
  
  <pre class="lang-none prettyprint-override"><code>Partition Key | Row_Num() | Partition Number  
  Apple         | 1         | 1
  Apple         | 2         | 1
  Oranges       | 1         | 2
  Oranges       | 2         | 2
  Pear          | 1         | 3
  Pear          | 2         | 3
  </code></pre>
  
  <p>Basically, apart from row_num() which gives us unique value within each "window", I want to have a number which is unique for each "window"
  How do I achieve this ? Is there any built in function in postgres for this ? </p>