SQL Commands | Database Applications | Pass Guaranteed -
A+ Graded
Section 1: Data Query Language (DQL) - SELECT Fundamentals
(Q1-18)
Q1. Consider the following table structure:
sqlCopy
CREATE TABLE employees (
emp_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
department VARCHAR(50),
salary DECIMAL(10,2)
);
Which query correctly retrieves only the first and last names of all employees?
A. SELECT * FROM employees WHERE first_name, last_name;
B. SELECT first_name AND last_name FROM employees;
C. SELECT first_name, last_name FROM employees; [CORRECT]
D. GET first_name, last_name FROM employees;
,Rationale: The correct syntax uses SELECT followed by comma-separated column
names and FROM to specify the table. Option A incorrectly places columns after WHERE,
B uses AND instead of a comma, and D uses invalid GET keyword.
Correct Answer: C
Q2. Given the employees table from Q1, which query retrieves all columns for all rows?
A. SELECT ALL FROM employees;
B. SELECT * FROM employees; [CORRECT]
C. SELECT EVERYTHING FROM employees;
D. SELECT columns FROM employees;
Rationale: The asterisk (*) is the ANSI SQL wildcard for all columns. Option A uses ALL
incorrectly (it modifies SELECT for duplicates, not column selection), C is not valid SQL,
and D is syntactically incorrect.
Correct Answer: B
Q3. Consider the employees table with the following data:
Table
emp_id first_name last_name department salary
, 1 John Smith Sales 5000
0
2 Jane Doe Sales 5500
0
3 Bob Johnson IT 6000
0
4 Alice Williams IT 6000
0
Which query returns only unique department names?
A. SELECT department FROM employees GROUP BY department;
B. SELECT UNIQUE department FROM employees;
C. SELECT DISTINCT department FROM employees; [CORRECT]
D. SELECT department FROM employees DISTINCT;
Rationale: DISTINCT eliminates duplicate rows and must appear immediately after
SELECT. Option A groups but doesn't necessarily return only unique values without
aggregation, B uses incorrect UNIQUE keyword, and D places DISTINCT in the wrong
position.
Correct Answer: C
Q4. Given the employees table, which query returns the first 3 rows only?
, A. SELECT * FROM employees LIMIT 3; [CORRECT]
B. SELECT * FROM employees TOP 3;
C. SELECT FIRST 3 * FROM employees;
D. SELECT * FROM employees FIRST 3;
Rationale: LIMIT is the ANSI SQL:2023 standard for restricting result rows. Option B
uses TOP which is T-SQL (SQL Server) syntax and must appear after SELECT, C and D
use invalid syntax for limiting rows.
Correct Answer: A
Q5. Which query correctly uses TOP syntax for SQL Server to return the first 5 rows from
the employees table?
A. SELECT TOP 5 * FROM employees; [CORRECT]
B. SELECT * TOP 5 FROM employees;
C. SELECT * FROM employees TOP 5;
D. SELECT FIRST 5 * FROM employees;
Rationale: In T-SQL (SQL Server), TOP must appear immediately after SELECT. Options
B, C, and D all place TOP or FIRST in incorrect positions within the query.
Correct Answer: A
Q6. Consider this query: