title: Rank from a number until it gets to the same number SQL
body: <p>I have a SQL question, that should be solved with rank or row_number (I think), but I don't know how. </p>
  
  <p>I have a table that shows the behavior of app users. The user can click the menu button in the app, and then the app shows different products (inside the menu view). So, each row in my table is a click that the user does inside the app.</p>
  
  <p>In the table there is the 'menu' column and the 'product' column. If the user clicks the menu button, the 'menu' column takes the value 1. If the user clicks anything else, it is 0. Inside the menu, the user can click different products, so for each product clicked, the 'product' column' is 1.</p>
  
  <p>So, i want to know how many products did the user clicked in a menu view. I also have the date, the platform (iOS or Android), the country, the user id and the session id. Everything that happens in 30 minutes, is inside a session, and a session is related only to one user. Both user id and session id are unique.</p>
  
  <p>The table is like this:</p>
  
  <p><a href="https://i.stack.imgur.com/uyp4K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uyp4K.png" alt="enter image description here"></a></p>
  
  <p>This table shows that user AAA opened the menu and then clicked 2 different products, user BBB opened the menu once in one session and didn't click anything, and then opened again and didn't click anything. Finally, the user CCC clicked the menu and then opened 2 products in the first session, and then in another session he/she clicked the menu and opened one product.</p>
  
  <p>I want something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/L9d6G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L9d6G.png" alt="enter image description here"></a></p>
  
  <p>I've tried using rank and row_number, and i can get the same rank for the rows of the products, but i can't get the menu row to have the same rank number than the products row.</p>
  
  <p>I hope you can help me :(</p>