title: How to join a table to itself using rank multiple times?
body: <p>I apologize if there is an existing solution, I tried searching quite a bit but couldnt find much.</p>
  
  <p>Here's what I am trying to do: </p>
  
  <p>I have a table that resembles the first image. I want it to look like the second image. Basically every time <code>rnk_address = 1</code>, I want that row's <code>order_date</code> to be moved into a separate column for that associated <code>user_id</code>.</p>
  
  <p>I'm ultimately trying to calculate the average difference in <code>order_date</code> between all <code>rnk_address = 1</code>, by <code>user_id</code>.</p>
  
  <p>I added a <code>user_counter</code> column using rank because I imagine I will need to do some time of join where i do <code>user_rank = user_rank + 1</code>? But not sure....</p>
  
  <p><strong>Original table:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/QX1ue.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QX1ue.png" alt="enter image description here"></a></p>
  
  <p><strong>End result:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Dx06g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dx06g.png" alt="enter image description here"></a></p>