title: SQL windows functions LEAD/LAG but only taking certain values into account?
body: <p>Let's say you have an app and want to know whether each install can be attributed to a new or returning user.<br />
  So you want to check for each ID who installed whether they have a login or register event later, whichever comes earlier.<br />
  How would you go from left table to right table?<br />
  It would be easy with a window function if I could say:</p>
  <pre><code> LAG(event,1) OVER (PARTITION BY id ORDER by event_timestamp)   
  </code></pre>
  <p>+but skip over 'install' events, jump over them</p>
  <p><a href="https://i.stack.imgur.com/W1Bdu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W1Bdu.png" alt="enter image description here" /></a></p>