Which keyword is used to eliminate duplicate rows from a SELECT query result?
A
UNIQUE B
REMOVE DUPLICATES C
DISTINCT D
ONLY
Analysis & Theory
DISTINCT removes duplicate rows in the result set.
What does the following query return? SELECT COUNT(*) FROM customers;
A
The sum of all numeric columns B
The total number of rows in 'customers' C
The average value of all columns D
All rows and columns in 'customers'
Analysis & Theory
COUNT(*) counts all rows in the table.
Which clause specifies the table from which to retrieve data?
A
FROM B
INTO C
TABLE D
SOURCE
Analysis & Theory
The FROM clause specifies the source table.
How do you rename a column in the SELECT output?
A
SELECT column RENAME alias B
SELECT column AS alias C
SELECT alias = column D
SELECT column TO alias
Analysis & Theory
Use AS to assign an alias to a column: SELECT column AS alias.
What does the LIMIT clause do?
A
Limits column names B
Limits the number of returned rows C
Limits the length of string columns D
Limits the number of tables
Analysis & Theory
LIMIT restricts the number of rows returned by the query.
Which query selects only rows where the 'age' column is greater than 30?
A
SELECT * FROM users WHERE age > 30; B
SELECT * FROM users HAVING age > 30; C
SELECT * FROM users GROUP BY age > 30; D
SELECT * FROM users ORDER BY age > 30;
Analysis & Theory
WHERE filters individual rows based on a condition.
How do you select unique values from the 'city' column in the 'addresses' table?
A
SELECT UNIQUE city FROM addresses; B
SELECT ONLY city FROM addresses; C
SELECT DISTINCT city FROM addresses; D
SELECT city DISTINCT FROM addresses;
Analysis & Theory
SELECT DISTINCT column returns unique values.
Which query selects all columns and orders the results by 'created_at' ascending?
A
SELECT * FROM posts ORDER BY created_at ASC; B
SELECT ALL FROM posts SORT BY created_at ASC; C
SELECT * FROM posts SORT created_at ASC; D
SELECT * FROM posts ORDER created_at ASC;
Analysis & Theory
ORDER BY column ASC sorts results in ascending order.
How do you select rows where 'status' is either 'active' or 'pending'?
A
SELECT * FROM accounts WHERE status IN ('active', 'pending'); B
SELECT * FROM accounts WHERE status = ('active' OR 'pending'); C
SELECT * FROM accounts WHERE status EQUALS ('active', 'pending'); D
SELECT * FROM accounts WHERE status MATCHES ('active', 'pending');
Analysis & Theory
Use WHERE column IN (value1, value2) for multiple matching values.
What does the BETWEEN operator do in a WHERE clause?
A
Checks if a value matches any in a list B
Tests if a value falls within a specified range C
Combines multiple conditions D
Sorts results between two columns
Analysis & Theory
BETWEEN checks if a value is within a range, inclusive of the endpoints.