title: Window Functions
body: <p>I want to add a window functions. </p>
  
  <p>Take the <code>min</code> date when visit = Y and end as Associd. </p>
  
  <p>TableA</p>
  
  <pre><code>ID    Date      AssocId  Visit
   1     1/1/17    10101     Y
   1     1/2/17    10102     Y
  </code></pre>
  
  <p>End Results.</p>
  
  <pre><code>ID    Date    AssocId
   1    1/1/17    10101
  </code></pre>
  
  <p>SQL > This gives me the min date but I need the AssocId associated to that date.</p>
  
  <pre><code> SELECT MIN(CASE WHEN A.VISIT = 'Y'
   THEN A.DATE END) OVER (PARTITION BY ID) 
   AS MIN_DT,
  </code></pre>