Codewars SQL
Kata 7kyu
Easy SQL: Counting and Grouping
Given a demographics table in the following format:
** demographics table schema **
- id
- name
- birthday
- race
you need to return a table that shows a count of each race represented, ordered by the count in descending order as:
** output table schema **
- race
- count
Hint: “group by race” can give us the unique race in the input table!
Solution:
select count(*) as count, race
from demographics
group by race
order by count desc;