title: Count number of records returned by temp table - SQL Server
body: <p>My script is as below</p>
  
  <pre><code>CREATE TABLE #t (Id int, Name varchar(10))
  INSERT INTO #t VALUES (1, 'A')
  INSERT INTO #t VALUES (1, 'B')
  INSERT INTO #t VALUES (1, 'C')
  INSERT INTO #t VALUES (1, 'D')
  INSERT INTO #t VALUES (2, 'E')
  
  SELECT COUNT(0)FROM (SELECT COUNT(0) FROM #t GROUP BY Id) a
  </code></pre>
  
  <p>but I am getting an error</p>
  
  <blockquote>
    <p>Msg 8155, Level 16, State 2, Line 5
    No column name was specified for column 1 of 'A'.</p>
  </blockquote>