AnalystPath

Course Fee per Campus

SQLEasyJunior level~15 min

Problem

A training company runs the same courses on three campuses and stores one row per (course, campus).

```
CourseFee
+-----------+---------+
| Column | Type |
+-----------+---------+
| course_id | int |
| campus | varchar |
| fee | int |
+-----------+---------+
(course_id, campus) is the primary key.
campus is one of ('north','central','south').
fee is the price of the course at that campus.
```

Write a query that returns one row per course with a separate column for each campus fee: `course_id`, `north`, `central`, `south`. If a course is not offered on a campus, that column should be NULL.

Return the result in any order.

Tables

Example rows — the live problem includes the full dataset.

CourseFee
course_idcampusfee
1north320
1south340
1central330

Expected output

Your answer should return 2 rows with the columns course_id, north, central, south.

Starter code (SQL)

SELECT *
FROM CourseFee;

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