Suppose we have a table "Person" as below and we need to find out the frequency of each age.
| Id |
LastName |
FirstName |
Age |
City |
| 1 |
Smith |
John |
33 |
Newyork |
| 2 |
Smith |
Mike |
34 |
Boston |
| 3 |
Paul |
Ryan |
39 |
Chicago |
| 4 |
William |
Brian |
45 |
Baltimore |
| 5 |
Rao |
Sunita |
41 |
Dayton |
| 6 |
Zing |
Sue |
33 |
Owings Mills |
| 7 |
Smith |
Robert |
45 |
Newyork |
| 8 |
Paul |
Zean |
33 |
Chicago |
| 9 |
Srivastava |
Hemant |
33 |
Baltimore |
| 10 |
Rao |
Venkat |
45 |
Dayton |
We could find out the frequency distribution by following the SQL query.
SELECT
Age,
COUNT(Age) AS Frequency
FROM
Persons
GROUP BY
Age
ORDER BY
COUNT(Age) DESC