title: Query is not working in SQL Server Management Studio
body: <p>I have this query with works for e.g. in FlySpeed SQL Query app but not in Microsoft SQL Server Management Studio:</p>
  
  <pre><code>SELECT *
  FROM
      table1 t
  JOIN 
      (SELECT 
           col1, col2, CONVERT(date, col3) as dt
       FROM 
           table1
       GROUP BY 
           col1, col2, dt
       HAVING 
           COUNT(*) &gt; 1) temp ON t.col1 = temp.col1                  
                              AND t.col2 = temp.col2 
                              AND CONVERT(date, t.col3) = dt
  ORDER BY 
      t.col1 desc
  </code></pre>
  
  <p>I get this in SSMS:</p>
  
  <blockquote>
    <p>Msg 207, Level 16, State 1, Line 5<br>
    Invalid column name 'dt'.</p>
  </blockquote>