Challenge - 5 Problems
Master of Selecting Specific Columns
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Selecting specific columns from a table
Given a table Employees with columns
id, name, department, and salary, what is the output of this query?SELECT name, salary FROM Employees WHERE department = 'Sales';
MySQL
SELECT name, salary FROM Employees WHERE department = 'Sales';
Attempts:
2 left
💡 Hint
The query selects only the name and salary columns for employees in the Sales department.
✗ Incorrect
The query filters employees by department 'Sales' and selects only the name and salary columns, so the output includes only those fields for matching rows.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in column selection
Which option contains a syntax error when selecting specific columns from the
Products table with columns product_id, product_name, and price?Attempts:
2 left
💡 Hint
Check if commas separate the column names.
✗ Incorrect
Option C misses a comma between product_id and product_name, causing a syntax error.
❓ query_result
advanced2:00remaining
Selecting columns with aliasing
What is the output of this query on the
Orders table with columns order_id, customer, and total?
SELECT order_id AS id, total AS amount FROM Orders WHERE total > 100;
MySQL
SELECT order_id AS id, total AS amount FROM Orders WHERE total > 100;
Attempts:
2 left
💡 Hint
The query renames columns using AS and filters totals greater than 100.
✗ Incorrect
The query renames order_id to id and total to amount, returning only those columns for orders with total > 100.
❓ optimization
advanced2:00remaining
Optimizing column selection for performance
You want to retrieve only the
username and email columns from a large Users table. Which query is the most efficient?Attempts:
2 left
💡 Hint
Selecting only needed columns reduces data transfer and processing.
✗ Incorrect
Option A selects only the required columns username and email, making it more efficient than selecting all columns or extra columns.
🔧 Debug
expert3:00remaining
Debugging incorrect column selection in join query
Given tables
Customers(id, name) and Orders(id, customer_id, amount), which query correctly selects customer names and their order amounts?Attempts:
2 left
💡 Hint
Check the join condition matches customer id with order's customer_id.
✗ Incorrect
Option B correctly joins Customers and Orders on Customers.id = Orders.customer_id and selects the desired columns.