Microsoft SQL Server Aggregate Functions COUNT(Column_Name) with GROUP BY Column_Name

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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


Got any Microsoft SQL Server Question?