SQL Skills Quiz: Aggregation and Datetime Mastery Quiz

  1. Extracting Month from a Date

    Which SQL function can be used to extract the month as a numerical value from a column named review_date?

    1. EXTRACT(MONTH FROM review_date)
    2. MONTHS(review_date)
    3. SELECT_MONTH(review_date)
    4. GETMONTH(review_date)
    5. DATE_MONTH(review_date)
  2. Grouping Queries

    If you want to display the average product rating by month, which clause should you use in your SQL statement to organize the data by those columns?

    1. GROUP BY
    2. COLLECT BY
    3. BUNDLED BY
    4. ORDERED BY
    5. PARTITION BY
  3. Averaging Column Values

    What aggregate function should you use to calculate the average rating for products in an SQL query?

    1. AVG()
    2. SUMM()
    3. COUNT()
    4. MEAN()
    5. TOTAL()
  4. Rounding Averages

    Which SQL function is used to round the average rating to exactly two decimal places?

    1. ROUND(AVG(rating), 2)
    2. AROUND(AVG(rating), 2)
    3. ROUNDUP(AVG(rating), 2)
    4. TRUNC(AVG(rating), 2)
    5. ROUNDING(AVG(rating), 2)
  5. Sorting Results

    To display results first by month and then by product_id, which clause and order should you write in SQL?

    1. ORDER BY month, product_id
    2. GROUP BY month, product_id
    3. SORT BY month, product_id
    4. FILTER BY month ASC, product_id ASC
    5. ARRANGE BY month, product_id
  6. Practical Query Structure

    Given a table called reviews with columns product_id, star_rating, and review_date, what is the correct alias use to show the extracted month as a column named month?

    1. EXTRACT(MONTH FROM review_date) AS month
    2. MONTH(review_date) month
    3. GET_MONTH(review_date) -u003E month
    4. EXTRACT(MONTH, review_date) FOR month
    5. MONTH_OF(review_date) month
  7. Identifying Typos in Function Names

    Which of the following is the correctly spelled and formatted aggregate function to find the average?

    1. AVG(value)
    2. AVRG(value)
    3. AVGE(value)
    4. AVEG(value)
    5. AVRGG(value)
  8. Aggregating with Multiple Columns

    When grouping data by both month and product_id and calculating averages, how should you structure your GROUP BY clause?

    1. GROUP BY month, product_id
    2. GROUP BY month product_id
    3. GROUP month AND product_id
    4. GROUP BY (month + product_id)
    5. GROUPED BY product_id THEN month
  9. Selecting and Aliasing

    If calculating the rounded average of star_rating, how do you correctly alias the result as avg_star_rating?

    1. ROUND(AVG(star_rating), 2) AS avg_star_rating
    2. ROUND(AVG(star_rating), 2) avg_star_rating
    3. ROUND(AVG(star_rating), 2) TO avg_star_rating
    4. AVG(star_rating) round as avg_star_rating
    5. AVG(star_rating, 2) AS avg_star_rating
  10. Order of SQL Clauses

    What is the correct order for these SQL clauses in a query: SELECT, FROM, GROUP BY, ORDER BY?

    1. SELECT, FROM, GROUP BY, ORDER BY
    2. FROM, SELECT, GROUP BY, ORDER BY
    3. SELECT, GROUP BY, FROM, ORDER BY
    4. ORDER BY, SELECT, FROM, GROUP BY
    5. FROM, SELECT, ORDER BY, GROUP BY