title: Reference column in WHERE EXISTS in a SQL Server CTE?
body: <p>I have a CTE in SQL Server with a WHERE EXISTS clause which I'm trying out instead of using joins.</p>
  
  <pre><code>WITH Work_Info AS
  (
    SELECT 
        a.fName,
        a.lName, 
        a.workID,
        a.carID
    FROM tbl_info a
    WHERE EXISTS (SELECT b.workID
                  FROM tbl_work b
                  WHERE a.workID = b.workID)
      AND EXISTS (SELECT c.carID, dbo.age_function(a.startDate, c.DOB) AS AGE
                  FROM tbl_car c
                  WHERE a.carID = c.carID
  )
  </code></pre>
  
  <p>I'm trying to use/reference the column aliased as <code>AGE</code> in statements following the CTE, for example:</p>
  
  <pre><code>update tble_info a
  SET adult =
     CASE WHEN AGE &lt; 18 THEN 'NO'
  </code></pre>