title: Postgres create id for groups
body: <p>I am trying to solve a problem that at the beginning looked quite easy but I couldn't find any (easy) solution</p>
  
  <p>I have a table with several columns and I want to create an ID over a group defined by some of the columns</p>
  
  <p>better to show on example, three columns and I want to have ID on groups defined by col1 and col2, which looks like a job for a window function, but somehow I failed to do it</p>
  
  <pre><code>col1 col2 col3 ID
  val1 valA x    1
  val1 valA y    1
  val1 valB y    2
  val2 valC z    3
  val3 valA v    4
  val3 valA r    4
  </code></pre>