SQL Query Mastery Quiz Quiz

  1. SQL UNION Queries

    What is the primary purpose of a union query in SQL?

    1. To create relationships between tables.
    2. To combine the result sets of two or more SELECT statements into a single result set.
    3. To update data across multiple tables simultaneously.
    4. To delete records based on conditions from different tables.
    5. Too update records in different tables.
  2. UNION Query Restrictions

    Which SQL operation is NOT typically allowed directly within a union query?

    1. Selecting data.
    2. Ordering the final result set.
    3. Filtering data.
    4. Updating data.
    5. Creating data.
  3. UNION ALL vs UNION

    What is the key difference between using 'UNION' and 'UNION ALL' when combining result sets in SQL?

    1. 'UNION ALL' automatically sorts the result set, while 'UNION' does not.
    2. 'UNION' includes duplicate rows, while 'UNION ALL' only includes distinct rows.
    3. 'UNION ALL' includes all rows, including duplicates, while 'UNION' removes duplicate rows.
    4. 'UNION' can only combine tables with the same number of columns, while 'UNION ALL' can combine tables with different number of columns.
    5. They are exactly the same and can be used interchangeably.
  4. Ordering in UNION Queries

    Where should the 'ORDER BY' clause be placed in a SQL query that uses 'UNION' to combine multiple 'SELECT' statements?

    1. Within each individual 'SELECT' statement.
    2. At the beginning of the entire query.
    3. At the end of the entire query, after the 'UNION' keyword.
    4. In the middle of the query.
    5. At the top of each select query
  5. Number of Columns in UNION

    What is a requirement when combining SELECT statements using UNION in SQL?

    1. The SELECT statements must select from the same table.
    2. The SELECT statements must select the same number of columns.
    3. The SELECT statements must filter the data with the same WHERE clause.
    4. The SELECT statements must order the data with the same ORDER BY clause.
    5. The SELECT statements must return different data types.
  6. SQL JOIN Clauses

    What type of JOIN returns only the rows that have matching values in both tables involved?

    1. LEFT JOIN
    2. RIGHT JOIN
    3. FULL OUTER JOIN
    4. INNER JOIN
    5. OUTER JOIN
  7. LEFT JOIN Behavior

    In a LEFT JOIN operation, if a row in the left table does not have a matching row in the right table, what values will be present for the columns from the right table in the result set?

    1. Zeroes
    2. Empty strings
    3. Undefined
    4. Null values
    5. Random values
  8. Filtering with WHERE

    If you need to limit the number of records displayed after running a query, which of the options best suit your needs?

    1. SORT BY
    2. ORDER BY
    3. WHERE
    4. LIMIT
    5. OFFSET
  9. Filtering and Sorting Data

    Which SQL clause is used to specify the order in which the rows should be returned in a query result?

    1. SORT BY
    2. WHERE
    3. GROUP BY
    4. HAVING
    5. ORDER BY
  10. Sorting SQL Data

    How can you sort the result set in descending order based on a column named 'date_column'?

    1. ORDER BY date_column ASC
    2. SORT BY date_column DESC
    3. ORDER date_column DESCENDING
    4. ORDER date_column DESC
    5. ORDER BY date_column ASCENDING