Counting and Total in Sql
Count
This counts the number of frequency
SELECT COUNT(*) FROM Country
#counts the number of rows in the Country Table
Count with Distinct
SELECT COUNT(DISTINCT COLUMN_NAME)
SELECT COUNT(DISTINCT States) as States
FROM Country
#counts the unique states in Country table
Count Aggregation
GROUP BY can be used with COUNT() in the same way as the other aggregation functions such as AVG(), MIN(), MAX().
Use the ORDER BY command to sort the values
-DESC will return the largest values to the smallest -ASC will return the smallest values to the largest