Microsoft SQL Server COUNT(Column_Name) with GROUP BY Column_Name


Example

Most of the time we like to get the total number of occurrence of a column value in a table for example:

TABLE NAME : REPORTS

ReportNameReportPrice
Test10.00 $
Test10.00 $
Test10.00 $
Test 211.00 $
Test10.00 $
Test 314.00 $
Test 314.00 $
Test 4100.00 $
SELECT  
    ReportName AS REPORT NAME, 
    COUNT(ReportName) AS COUNT 
FROM     
    REPORTS 
GROUP BY 
    ReportName 
REPORT NAMECOUNT
Test4
Test 21
Test 32
Test 41