Free Practice Quiz Question List

3 SQL Fundamentals Online Quiz Questions

Use this free practice quiz with 20 questions to review 3 SQL Fundamentals, test your knowledge, and prepare for your next test or exam.

20 questions
01
True or false
1 point

A SQL primary key can consist of more than one column.

  1. A

    True

  2. B

    False

02
Choose one
1 point

What does COUNT(category) count in a SQL query?

  1. A

    It counts every row, including rows where the column is NULL.

  2. B

    It counts only rows where the column is not NULL.

  3. C

    It counts only distinct values in the column.

  4. D

    It counts the number of columns in the table.

03
Written response
1 point

In SELECT name, price * 1.10 AS price_with_tax FROM products;, what alias is assigned to the calculated output column?

04
Fill in the blank
1 point

Complete each statement with the SQL operator that fits. Use to match one of several listed values, and use to test an inclusive range.

05
True or false
1 point

A SQL query without ORDER BY guarantees that its rows will appear in insertion order.

  1. A

    True

  2. B

    False

06
Choose all
1 point

Select all statements that correctly describe these SQL constraints.

  1. A

    NOT NULL requires a value for the column.

  2. B

    UNIQUE prevents duplicate values.

  3. C

    CHECK enforces a condition on allowed values.

  4. D

    CHECK guarantees that a column has a value.

07
Choose one
1 point

A query groups rows by category and calculates an average for each group. Which clause filters the resulting groups based on an aggregate condition?

  1. A

    WHERE filters groups after aggregation.

  2. B

    HAVING filters individual rows before grouping.

  3. C

    HAVING filters groups after aggregation.

  4. D

    WHERE and HAVING both filter only the final sorted results.

08
Written response
1 point

Which SQL operator phrase tests whether category has a NULL value?

09
Choose all
1 point

Select all statements that correctly describe NULL in SQL.

  1. A

    NULL represents a missing or unknown value.

  2. B

    NULL is not the same as zero.

  3. C

    NULL is not the same as an empty string.

  4. D

    category = NULL is the recommended way to test for a missing category.

10
Fill in the blank
1 point

In an ORDER BY clause, use to sort from lower to higher and to sort from higher to lower.

11
Choose one
1 point

In databases that support it, what does LIMIT 5 do when added to a query?

  1. A

    It specifies which columns are returned.

  2. B

    It filters rows based on a condition.

  3. C

    It restricts the number of rows returned.

  4. D

    It groups rows before calculating aggregates.

12
Open ended
1 point

Write a SQL query that returns each category's product count and average price using only in-stock products, keeps only categories with at least two such products, and sorts the results by average price from highest to lowest.

13
True or false
1 point

SQL syntax and available data types can vary slightly among database systems.

  1. A

    True

  2. B

    False

14
Choose one
1 point

What does SELECT * FROM products; request?

  1. A

    It returns only the first column in the table.

  2. B

    It requests all columns from the table.

  3. C

    It returns only columns with no NULL values.

  4. D

    It counts the rows in the table.

15
Choose one
1 point

A products table must reject any row with a negative price while allowing multiple products to have the same price. Which constraint best enforces this rule?

  1. A

    Use UNIQUE on price.

  2. B

    Use CHECK (price >= 0) on price.

  3. C

    Use DEFAULT 0 on price.

  4. D

    Use NOT NULL on price.

16
Choose one
1 point

A table has 12 rows, and category is NULL in 3 of them. Which statement correctly describes the results of COUNT(*) and COUNT(category)?

  1. A

    COUNT(category) counts every row, including rows where category is NULL.

  2. B

    COUNT(*) counts every row, while COUNT(category) excludes rows where category is NULL.

  3. C

    Both expressions count only rows where category is not NULL.

  4. D

    COUNT(*) counts only rows where every column is non-NULL.

17
Written response
1 point

In SELECT price * 1.10 ___ price_with_tax FROM products;, which SQL keyword belongs in the blank to name the expression result price_with_tax?

18
Choose one
1 point

You need a query to return products priced below 25 that also have at least one item in stock. Which condition correctly filters individual product rows?

  1. A

    Use WHERE price < 25 OR in_stock > 0.

  2. B

    Use HAVING price < 25 AND in_stock > 0.

  3. C

    Use WHERE price < 25 AND in_stock > 0.

  4. D

    Use GROUP BY price < 25 AND in_stock > 0.

19
Choose one
1 point

A query selects category and COUNT(*) to report a product count for each category. Which GROUP BY clause matches that goal?

  1. A

    Add GROUP BY product_id.

  2. B

    Add GROUP BY category.

  3. C

    Add GROUP BY COUNT(*).

  4. D

    No GROUP BY clause is needed to calculate a count per category.

20
Written response
1 point

A query groups products by category and calculates COUNT(*). Which SQL clause should it use to keep only categories whose count is at least 2?