CSS - PMS - CCE - PCS - Basic Computing
Database Basics
A query written inside another query is called a:
A. Subquery
B. Form
C. Report
D. Index
Correct Answer: A
A subquery is nested inside another SQL statement and provides data to the outer query.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which SQL operator combines query results and keeps duplicates?
A. UNION ALL
B. UNION
C. DISTINCT
D. GROUP BY
Correct Answer: A
UNION ALL is faster in many cases because it keeps duplicate rows instead of removing them.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which SQL operator combines query results and removes duplicates?
A. UNION
B. UNION ALL
C. JOIN ALL
D. MERGE ONLY
Correct Answer: A
UNION combines compatible result sets and removes duplicate rows.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
A join in which a table is joined to itself is called a:
A. SELF JOIN
B. CROSS JOIN
C. FULL JOIN
D. UNION
Correct Answer: A
A self join uses aliases to compare or relate rows within the same table.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which join produces every possible combination of rows from two tables?
A. CROSS JOIN
B. INNER JOIN
C. LEFT JOIN
D. RIGHT JOIN
Correct Answer: A
CROSS JOIN produces the Cartesian product of the two tables.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which join returns matched and unmatched rows from both tables?
A. FULL OUTER JOIN
B. INNER JOIN
C. CROSS JOIN
D. SELF JOIN
Correct Answer: A
FULL OUTER JOIN includes all rows from both tables and uses NULL where no match exists.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which join returns all rows from the right table and matching rows from the left table?
A. RIGHT JOIN
B. LEFT JOIN
C. INNER JOIN
D. SELF JOIN
Correct Answer: A
RIGHT JOIN preserves every row from the right table and includes matching rows from the left.
CSS - PMS - CCE - PCS - Basic Computing
Database Basics
Which join returns all rows from the left table and matching rows from the right table?
A. LEFT JOIN
B. INNER JOIN
C. RIGHT JOIN
D. CROSS JOIN
Correct Answer: A
LEFT JOIN preserves every row from the left table and fills unmatched right-side values with NULL.
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.