AnalystPath

Counting Package Registries

SQLEasyJunior level~15 min

Problem

Table `Packages` lists software dependencies. Each row has a `pkg_id` and a `coordinate` string written as `name@registry`, for example `parser@npmjs.org`. The part before the `@` is the package name; the part after the `@` is the registry host.

Consider only coordinates whose registry host ends in `.org`. For those, extract the registry host and count how many packages come from each one.

Return `registry` (the host after the `@`) and `pkg_count` (the number of packages from that registry), ordered by `registry` ascending.

Tables

Example rows — the live problem includes the full dataset.

Packages
pkg_idcoordinate
336hwkiy@crates.io
489adcmaf@maven.org
449vrzmwyum@pypi.org

Expected output

Your answer should return 2 rows with the columns registry, pkg_count.

Starter code (SQL)

SELECT *
FROM Packages;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions