Count from inner select statement

count, select, sql, sql-server

Solution

I suppose you just missed the name of the second column:

SELECT COUNT(*)
FROM (
    Select id, COUNT(id) count_of_id
    FROM [Testing].[dbo].[Bench]
    GROUP BY id
    HAVING COUNT(*) =5
);

Problem

I am trying to execute the following query in SQL server but I am getting error. Can somebody explain me how to count the inner select statement? ``` SELECT COUNT(*) from (Select ID, COUNT(ID) FROM [Testing].[dbo].[Bench] group by ID having COUNT(*) =5); ```

Original source