title: How to Reference a Subquery in the Select Clause of a SQL statement
body: <p>I have a SQL query that looks like this:</p>
  
  <pre><code>DECLARE @I int
  
  SET @I = (SELECT W.PMon FROM WHouse.dbo.Rundate AS W)
  
  SELECT L.ACCOUNT, 
  L.ID,
  L.OPENDATE, 
  L.ORIGINALBALANCE, 
  L.BALANCE, 
  L.DUEDATE,
  (SELECT N.BIRTHDATE FROM Sym.dbo.NAME AS N WHERE N.Account = L.Account and  N.ORDINAL = 0) AS 'PBD',
  (SELECT N.BIRTHDATE FROM Sym.dbo.LOANNAME AS N WHERE L.Account = N.Account and L.ID = N.PARENTID and N.TYPE IN (01, 16, 20, 21)) AS 'JBD',
  L.CREDITSCORE
  
  FROM Sym.dbo.Loan AS L
  JOIN Sym.dbo.Account AS A
  ON L.Account = A.Account
  WHERE L.TYPE IN (0, 1, 2, 3, 14, 15, 23) and L.BALANCE &gt; 0 and L.CHARGEOFFDATE IS NULL and L.CLOSEDATE IS NULL and A.TYPE &lt;&gt; 5
  </code></pre>
  
  <p>In the WHERE clause, how do I reference the subqueries in the SELECT clause to do comparisons?</p>