CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which join returns only rows with matching values in both tables?
A. INNER JOIN
B. LEFT JOIN
C. FULL JOIN
D. CROSS JOIN
Correct Answer: A
INNER JOIN returns only rows that satisfy the join condition in both tables.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which keyword is commonly used to assign a temporary column or table name?
A. AS
B. IN
C. BY
D. ON
Correct Answer: A
AS creates an alias that makes a query result or table reference easier to read.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which statement correctly describes WHERE and HAVING?
A. WHERE filters rows; HAVING filters groups
B. WHERE sorts rows; HAVING creates tables
C. WHERE grants access; HAVING removes access
D. They always perform exactly the same task
Correct Answer: A
WHERE is applied before grouping, while HAVING is applied to grouped results.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which clause filters grouped or aggregated results?
A. HAVING
B. WHERE
C. ORDER BY
D. AS
Correct Answer: A
HAVING filters groups after GROUP BY and aggregate functions have been applied.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which clause groups rows that have the same values?
A. GROUP BY
B. ORDER BY
C. WHERE
D. VALUES
Correct Answer: A
GROUP BY combines rows into groups for aggregate calculations.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which aggregate function returns the largest value?
A. MAX
B. MIN
C. AVG
D. DISTINCT
Correct Answer: A
MAX returns the highest value in the selected column or expression.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which aggregate function returns the smallest value?
A. MIN
B. MAX
C. SUM
D. COUNT
Correct Answer: A
MIN returns the lowest value in the selected column or expression.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which aggregate function calculates the arithmetic mean?
A. AVG
B. SUM
C. MAX
D. COUNT
Correct Answer: A
AVG returns the average of non-NULL numeric values.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which aggregate function calculates a total?
A. SUM
B. AVG
C. MIN
D. COUNT
Correct Answer: A
SUM adds the numeric values in a column or expression.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
What does COUNT(column_name) count?
A. Non-NULL values in the column
B. All rows including every NULL
C. Only duplicate values
D. Only table names
Correct Answer: A
COUNT(column_name) counts rows where that specific column is not NULL.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
What does COUNT(*) return?
A. The number of rows
B. The sum of all numeric values
C. The first row only
D. The table name
Correct Answer: A
COUNT(*) counts all rows in the result, including rows containing NULL values.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which condition correctly checks for missing values?
A. IS NULL
B. = NULL
C. LIKE NULL
D. IN NULL
Correct Answer: A
NULL must be tested using IS NULL or IS NOT NULL rather than ordinary equality.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
The SQL BETWEEN operator normally includes:
A. Both boundary values
B. Neither boundary value
C. Only the lower boundary
D. Only the upper boundary
Correct Answer: A
BETWEEN is inclusive of both the lower and upper boundary values.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which operator tests whether a value belongs to a list?
A. IN
B. LIKE
C. BETWEEN
D. AS
Correct Answer: A
IN checks whether an expression matches any value in a specified list or subquery.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
In a LIKE pattern, the underscore (_) represents:
A. Exactly one character
B. Any sequence of characters
C. A NULL value
D. A table name
Correct Answer: A
The underscore wildcard matches exactly one character.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
In a LIKE pattern, the percent sign (%) represents:
A. Any sequence of characters
B. Exactly one character
C. Only numeric values
D. A primary key
Correct Answer: A
The percent wildcard matches zero or more characters.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which operator is used for pattern matching in SQL?
A. LIKE
B. BETWEEN
C. IN
D. IS NULL
Correct Answer: A
LIKE performs pattern matching, commonly with percent and underscore wildcards.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which keyword removes duplicate rows from a SELECT result?
A. DISTINCT
B. UNIQUE TABLE
C. REMOVE
D. DELETE
Correct Answer: A
DISTINCT returns only unique combinations of the selected column values.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
What is the default sort direction of ORDER BY in most SQL systems?
A. Ascending
B. Descending
C. Random
D. Unsorted only
Correct Answer: A
ORDER BY normally sorts in ascending order unless DESC is specified.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which clause sorts query results?
A. ORDER BY
B. GROUP BY
C. WHERE
D. VALUES
Correct Answer: A
ORDER BY sorts result rows by one or more columns.