Kata 7kyu

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;

Link

--

--

--

My homepage to record my thought processes for solving SQL and Algorithm questions

Recommended from Medium

TickTime Time manager REVIEW | MacSources

Let’s Go, Create an Awesome REST Api in Go — Part II

CS 371p Spring 2022: Adhan Razzaque

BetaMars Second Closed Beta Test will be Open for Access on March 9! Are You Ready?

A guide to Apdex score: Calculations, improvements, and more

Immutable behavior of Java String

11 Things To Follow In Order To Improve Your Daily Stand-ups

GIT & GITHUB — Getting started

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Isabelle

Isabelle

In love with telling stories with data

More from Medium

SQL Introduction 1

An internal hard drive

Basic commands for Oracle SQL

Embedded SQL and Dynamic SQL a

How to draw with SQL?