And Solutions 2025/2026 Rated A+
SECTION 1: SQL QUERY WRITING (SELECT, FROM, WHERE, ORDER BY, GROUP BY, HAVING
CLAUSES) — 8 Questions
Q1: Which clause in a SELECT statement is evaluated first during query execution?
A. SELECT
B. FROM
C. WHERE
D. ORDER BY
Correct Answer: B
Rationale: Correct because the FROM clause is evaluated first to identify the source table(s),
followed by WHERE, GROUP BY, HAVING, SELECT, and finally ORDER BY per SQL standard (ANSI)
query execution order.
Q2: A database analyst needs to retrieve all employees from the employees table where the
department is 'Sales' and the salary is greater than 50000. Which WHERE clause correctly
implements this logic?
A. WHERE department = 'Sales' OR salary > 50000
B. WHERE department = 'Sales' AND salary > 50000
C. WHERE department = 'Sales' AND salary >= 50000
D. WHERE department IS 'Sales' AND salary > 50000
Correct Answer: B
Rationale: Correct because the AND logical operator requires both conditions to be true
simultaneously, and the comparison operator > strictly excludes 50000, matching the
requirement for salaries greater than 50000.
Q3: Which query correctly retrieves product names from the products table where the
product_name starts with the letter 'S'?
, A. SELECT product_name FROM products WHERE product_name LIKE 'S%'
B. SELECT product_name FROM products WHERE product_name LIKE '%S'
C. SELECT product_name FROM products WHERE product_name LIKE 'S%'
D. SELECT product_name FROM products WHERE product_name LIKE 'S'
Correct Answer: A
Rationale: Correct because the % wildcard matches zero or more characters following 'S', which
properly filters for product names beginning with 'S' per SQL standard pattern matching syntax.
Q4: The following query is executed: SELECT * FROM orders WHERE order_date BETWEEN
'2024-01-01' AND '2024-03-31'. Which statement accurately describes the result set?
A. Returns orders from January 1 through March 30, 2024
B. Returns orders from January 1 through March 31, 2024, inclusive
C. Returns orders from January 2 through March 31, 2024
D. Returns orders from January 1 through April 1, 2024
Correct Answer: B
Rationale: Correct because the BETWEEN operator in SQL is inclusive of both boundary values,
meaning orders on both January 1, 2024 and March 31, 2024 are included in the result set.
Q5: A report requires customer records sorted first by country in ascending order, then by city in
descending order within each country. Which ORDER BY clause achieves this?
A. ORDER BY country DESC, city ASC
B. ORDER BY country, city DESC
C. ORDER BY country ASC, city
D. ORDER BY country DESC, city DESC
Correct Answer: B
Rationale: Correct because ASC is the default sort order and can be omitted for country, while
city requires explicit DESC to sort in descending order within each country grouping.
Q6: Which query correctly uses a CASE expression to categorize employees based on their
years_of_service?
A. SELECT CASE years_of_service WHEN > 10 THEN 'Veteran' ELSE 'New' END FROM employees
B. SELECT CASE WHEN years_of_service > 10 THEN 'Veteran' ELSE 'New' END FROM employees
C. SELECT CASE years_of_service > 10 THEN 'Veteran' ELSE 'New' END FROM employees
D. SELECT IF years_of_service > 10 THEN 'Veteran' ELSE 'New' FROM employees