Skip to content
C

Enrolled Both Years

Easysql
Learn the Concept: INTERSECT

Write a query returning every student_id enrolled in BOTH 2025 and 2026, ordered ascending.

sql
CREATE TABLE enrolled_2025 (student_id INTEGER NOT NULL); CREATE TABLE enrolled_2026 (student_id INTEGER NOT NULL);

Sample data:

sql
INSERT INTO enrolled_2025 (student_id) VALUES (1), (2), (3), (4); INSERT INTO enrolled_2026 (student_id) VALUES (2), (3), (5);

Related Problems

Input (stdin)

Output

Run your code to see output here...