0
0
SQLquery~20 mins

SELECT specific columns in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of SELECT specific columns
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Selecting specific columns from a table

Given a table Employees with columns id, name, department, and salary, what will be the output of this query?

SELECT name, salary FROM Employees;
SQL
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary INT);
INSERT INTO Employees VALUES (1, 'Alice', 'HR', 50000), (2, 'Bob', 'IT', 60000), (3, 'Charlie', 'Finance', 55000);
A[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}, {"id": 3, "name": "Charlie"}]
B[{"name": "Alice", "salary": 50000}, {"name": "Bob", "salary": 60000}, {"name": "Charlie", "salary": 55000}]
C[{"department": "HR", "salary": 50000}, {"department": "IT", "salary": 60000}, {"department": "Finance", "salary": 55000}]
D[{"id": 1, "department": "HR"}, {"id": 2, "department": "IT"}, {"id": 3, "department": "Finance"}]
Attempts:
2 left
💡 Hint

Look at the columns listed after SELECT. Only those columns will appear in the output.

query_result
intermediate
2:00remaining
Selecting columns with WHERE clause

What will be the output of this query on the Employees table?

SELECT id, name FROM Employees WHERE salary > 55000;
SQL
CREATE TABLE Employees (id INT, name VARCHAR(50), department VARCHAR(50), salary INT);
INSERT INTO Employees VALUES (1, 'Alice', 'HR', 50000), (2, 'Bob', 'IT', 60000), (3, 'Charlie', 'Finance', 55000);
A[{"id": 3, "name": "Charlie"}]
B[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
C[{"id": 2, "name": "Bob"}]
D[{"id": 2, "name": "Bob"}, {"id": 3, "name": "Charlie"}]
Attempts:
2 left
💡 Hint

Only rows where salary is greater than 55000 are included.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in selecting columns

Which option contains a syntax error when selecting specific columns from the Employees table?

ASELECT id name FROM Employees;
BSELECT id, name FROM Employees;
CSELECT name, salary FROM Employees;
DSELECT department FROM Employees;
Attempts:
2 left
💡 Hint

Check if commas separate the column names correctly.

optimization
advanced
2:00remaining
Optimizing column selection for performance

You want to retrieve only the name and department columns from a large Employees table. Which query is best for performance?

ASELECT * FROM Employees;
BSELECT id, name, department FROM Employees;
CSELECT name, department, salary FROM Employees;
DSELECT name, department FROM Employees;
Attempts:
2 left
💡 Hint

Select only the columns you need to reduce data transfer.

🧠 Conceptual
expert
2:00remaining
Understanding column selection with aliases

Consider this query:

SELECT name AS employee_name, salary AS employee_salary FROM Employees;

What will be the column names in the output?

A["employee_name", "employee_salary"]
B["name AS employee_name", "salary AS employee_salary"]
C["name", "salary"]
D["employee", "salary"]
Attempts:
2 left
💡 Hint

Look at the AS keyword which renames columns in the output.