Union: Honors or Dean's List
Mediumsql
Two tables track student distinctions: honors_students and deans_list, each just a student_id column. Write a query implementing the Union of both — every distinct student_id that appears on either list — ordered ascending.
sqlCREATE TABLE honors_students (student_id INTEGER NOT NULL); CREATE TABLE deans_list (student_id INTEGER NOT NULL);
Sample data (this is what your query runs against when you press Run):
sqlINSERT INTO honors_students (student_id) VALUES (1), (2), (5); INSERT INTO deans_list (student_id) VALUES (2), (3);
Example 1
Input
(none)
Output
student_id 1 2 3 5
SQL's UNION combines both queries' rows and removes duplicates automatically, matching set-based Union semantics. Reference: SELECT student_id FROM honors_students UNION SELECT student_id FROM deans_list ORDER BY student_id;