0
0
SQLquery~30 mins

EXCEPT (MINUS) for differences in SQL - Mini Project: Build & Apply

Choose your learning style9 modes available
Find Unique Customers Using EXCEPT
📖 Scenario: You work for a retail company that has two sales regions: East and West. Each region has a list of customers who made purchases. You want to find customers who bought from the East region but not from the West region.
🎯 Goal: Build an SQL query using EXCEPT to find customers who purchased only in the East region and not in the West region.
📋 What You'll Learn
Create a table called east_customers with a single column customer_name and insert these exact customers: 'Alice', 'Bob', 'Charlie'
Create a table called west_customers with a single column customer_name and insert these exact customers: 'Bob', 'Diana'
Write a query using EXCEPT to select customers from east_customers who are not in west_customers
💡 Why This Matters
🌍 Real World
Retail companies often need to compare customer lists from different regions or time periods to find unique customers or changes in buying patterns.
💼 Career
Knowing how to use EXCEPT or MINUS helps database analysts and developers write queries that compare datasets efficiently, a common task in data analysis and reporting.
Progress0 / 4 steps
1
Create the east_customers table and insert data
Create a table called east_customers with one column customer_name of type VARCHAR(50). Insert these exact customers: 'Alice', 'Bob', and 'Charlie'.
SQL
Need a hint?

Use CREATE TABLE to make the table and INSERT INTO with multiple VALUES to add customers.

2
Create the west_customers table and insert data
Create a table called west_customers with one column customer_name of type VARCHAR(50). Insert these exact customers: 'Bob' and 'Diana'.
SQL
Need a hint?

Repeat the table creation and insertion steps for the west_customers table.

3
Write the EXCEPT query to find unique East customers
Write an SQL query that selects customer_name from east_customers except those in west_customers. Use EXCEPT to find customers who bought only in the East region.
SQL
Need a hint?

Use SELECT from both tables and connect them with EXCEPT to get the difference.

4
Complete the query with ordering
Add an ORDER BY customer_name clause at the end of your EXCEPT query to list the unique East customers alphabetically.
SQL
Need a hint?

Use ORDER BY customer_name after the EXCEPT query to sort the output.