Set operations with ORDER BY in SQL
📖 Scenario: You work in a small bookstore that keeps two separate tables for new arrivals and best sellers. You want to create a combined list of book titles from both tables, sorted alphabetically.
🎯 Goal: Build an SQL query that combines book titles from two tables using a set operation and sorts the combined list alphabetically using ORDER BY.
📋 What You'll Learn
Create two tables named
new_arrivals and best_sellers with a single column title.Insert the exact book titles into each table as specified.
Write a query that uses
UNION to combine titles from both tables.Add
ORDER BY title ASC to sort the combined list alphabetically.💡 Why This Matters
🌍 Real World
Combining data from multiple sources and sorting it is common in reporting and data analysis for businesses.
💼 Career
Understanding set operations and sorting in SQL is essential for database querying roles, data analysts, and backend developers.
Progress0 / 4 steps