Get frequency of a column in SQL Server
count, select, sql, sql-server
Solution
Use aggregate functions
Select column, count(*)
From table
Group By column
This will return one row that contains the count, for each distinct value in column
Problem
I have a column with values like 1,1,2,1,... and I would want to get the frequency of 1 and 2, I did ``` SELECT count(column) FROM table WHERE column = 1; SELECT count(column) FROM table WHERE column = 2; ``` But, could I take the frequency with a more direct way?