AnalystPath

Middle-Tier Workshop Topics

SQLMediumMid level~15 min

Problem

Table: `Attendee`

```text
+----------+---------+
| Column | Type |
+----------+---------+
| person_id| int |
| fullname | varchar |
| topic | varchar |
+----------+---------+
person_id is the primary key. Each row says which workshop topic a person
signed up for. topic references a row in the Topic table.
```

Table: `Topic`

```text
+----------+---------+
| Column | Type |
+----------+---------+
| topic_id | int |
| topic | varchar |
+----------+---------+
topic_id is the primary key.
```

Find the workshop topics that are **neither the least popular nor the most popular** — that is, every topic whose sign-up count is **strictly greater than the smallest** topic's count **and strictly less than the largest** topic's count. Return the column `topic`. Rows may be in any order.

**Example**

```text
Attendee:
+-----------+----------+----------+
| person_id | fullname | topic |
+-----------+----------+----------+
| 1 | Ada | Welding |
| 2 | Bo | Welding |
| 3 | Cy | Welding |
| 4 | Di | Pottery |
| 5 | Ed | Pottery |
| 6 | Fi | Origami |
+-----------+----------+----------+

Output:
+----------+
| topic |
+----------+
| Pottery |
+----------+
```

Welding has 3 sign-ups (most), Origami has 1 (fewest), and Pottery has 2 — strictly between — so only Pottery is returned.

Tables

Example rows — the live problem includes the full dataset.

Attendee
person_idfullnametopic
1AdaWelding
2BoWelding
3CyWelding
Topic
topic_idtopic
1Welding
2Pottery
3Origami

Expected output

Your answer should return 1 row with the columns topic.

Starter code (SQL)

SELECT *
FROM Attendee;

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