title: SQL: Help identifying patterns
body: <p>I have a table that looks like this: </p>
  
  <p><img src="https://i.stack.imgur.com/fW3bR.png" alt="enter image description here"></p>
  
  <p>What I am trying to do is consolidate groups based on the same ResourceName and Permissions and give them the same unique identifier. However I have groups repeating themselves for multiple ResourceNames and cannot give the same group another unique ID. </p>
  
  <p>For instance, GroupAdmin and GroupUser1 will be one set with an ID and GroupUser2 and GroupUser3 would be another set. I have millions of rows like this. </p>
  
  <p>Please help me write a query or some code to figure this out. Thanks!!</p>
  
  <p><strong>EDIT</strong>added table without picture</p>
  
  <pre><code>ResourceName    Permissions        GroupName
  Resource1           Modify             GroupAdmin
  Resource1           Modify             GroupUser1
  Resource1           Read &amp; Execute         GroupUser2
  Resource1           Read &amp; Execute         GroupUser3
  Resource2           Modify             GroupAdmin
  Resource2           Modify             GroupUser1
  Resource2           Read &amp; Execute         GroupUser2
  Resource2           Read &amp; Execute         GroupUser3
  Resource3           Modify             GroupAdmin
  Resource3           Modify             GroupUser1
  Resource3           Read &amp; Execute         GroupUser2
  Resource3           Read &amp; Execute         GroupUser3
  Resource4           Modify             GroupAdmin
  Resource4           Modify             GroupUser1
  Resource4           Read &amp; Execute         GroupUser2
  Resource4           Read &amp; Execute         GroupUser3
  </code></pre>