title: SQL Server 2008 joining two queries
body: <p>I'm overlooking something trivial here.  This query isn't for any reason in particular other than trying to practice joining two queries.  The errors that I get are</p>
  
  <pre><code>Msg 156, Level 15, State 1, Line 10
  Incorrect syntax near the keyword 'inner'.
  Msg 156, Level 15, State 1, Line 16
  Incorrect syntax near the keyword 'as'.
  </code></pre>
  
  <p>And the query is </p>
  
  <pre><code>select t.countyName, x.countyName
      from
      (
  
      SELECT DISTINCT Patient.patientid, tblStateCounties.countyName, Patient.countyCode
      FROM         Patient INNER JOIN
                            tblStateCounties ON Patient.stateCode = tblStateCounties.stateCode AND Patient.countyCode = tblStateCounties.countyCode
      WHERE     (Patient.patientage &gt; 80)
      ) 
      inner join 
      (
      SELECT DISTINCT Patient.patientid, tblStateCounties.countyName, Patient.countyCode
      FROM         Patient INNER JOIN
                            tblStateCounties ON Patient.stateCode = tblStateCounties.stateCode AND Patient.countyCode = tblStateCounties.countyCode
      WHERE     (Patient.patientage &lt; 80)
      ) as x on t.countyname=x.countyname
  </code></pre>