& Database Mastery
.
Section 1: SQL Fundamentals & Query Basics (Q1 - Q30)
Question 1
Which SQL clause is used to filter rows before grouping occurs?
A) HAVING
B) WHERE
C) GROUP BY
D) ORDER BY
Answer: B
Rationale: The WHERE clause is applied to individual rows before any grouping or
aggregation takes place. The HAVING clause filters groups after the GROUP BY has
been processed .
Question 2
What is the default sort order of the ORDER BY clause?
A) Descending
,B) Ascending
C) Random
D) No default
Answer: B
Rationale: In SQL, if you do not specify ASC (Ascending) or DESC (Descending)
after your ORDER BY clause, the database engine defaults to sorting the result set
in ascending order .
Question 3
Which wildcard character matches exactly one single character in a LIKE clause?
A) %
B) _
C) *
D) ?
Answer: B
Rationale: The underscore _ represents a single character in SQL pattern
matching. The percent sign % represents zero, one, or multiple characters .
,Question 4
What does the query SELECT COUNT(*) FROM employees; return?
A) The number of non-null values in the employees table
B) The total number of rows in the employees table
C) The sum of all numeric columns
D) The average of all rows
Answer: B
Rationale: COUNT(*) counts every row in the result set, including rows with NULL
values. If you use COUNT(column_name), it excludes NULLs .
Question 5
Which statement deletes all rows from a table but keeps the table structure
intact?
A) DROP TABLE employees;
B) TRUNCATE TABLE employees;
C) DELETE * FROM employees;
D) REMOVE TABLE employees;
Answer: B
, Rationale: TRUNCATE TABLE is a DDL command that removes all rows quickly and
resets auto-increment counters, but keeps the table schema for future use. DROP
TABLE removes the table entirely .
Question 6
What does the ROUND(15.678, 2) function return?
A) 15
B) 15.68
C) 15.67
D) 16
Answer: B
Rationale: The ROUND function rounds a number to a specified number of
decimal places. Here, 15.678 rounded to 2 decimal places is 15.68 .
Question 7
What is the purpose of the ALTER TABLE statement?
A) Delete rows from a table
B) Change the structure of an existing table
C) Remove a table from the database