All problems

What Industries Do Our Customers Come From?

easySQLGroupBy

Loopwire's sales team is choosing which industry to go after next quarter, and the first slide of that discussion is simply what the current customer base is made of.

Every customer company has one industry recorded against it, as a short text label. There is no separate list of industries in the database, so the categories have to come out of the account rows themselves — and with eight customers spread thinly, several of those categories will hold exactly one company.

accounts — one row per customer company. industry is the sector label. signup_date is the day they became a customer.

id company_name industry signup_date
1 Northwind Traders retail 2022-11-03
2 Vertex Analytics software 2022-12-15
3 Bluepeak Logistics logistics 2023-01-20
4 Fernwood Studio media 2023-02-05
5 Cobalt Health healthcare 2023-02-18
6 Ridgeline Capital finance 2023-03-01
7 Sable & Co retail 2023-03-22
8 Hearth Robotics manufacturing 2023-04-10

The table already exists in the database — there is nothing to create or load.

Task: Write a query returning two columns, industry and num_accounts, with one row for every sector that has at least one customer in it. A sector with no customers produces no row. Rows come back in alphabetical order of industry.

Example output — shape only, on invented sectors and counts.

industry num_accounts
education 4
energy 9
hospitality 3

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…