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?
- EXTRACT(MONTH FROM review_date)
- MONTHS(review_date)
- SELECT_MONTH(review_date)
- GETMONTH(review_date)
- DATE_MONTH(review_date)
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?
- GROUP BY
- COLLECT BY
- BUNDLED BY
- ORDERED BY
- PARTITION BY
Averaging Column Values
What aggregate function should you use to calculate the average rating for products in an SQL query?
- AVG()
- SUMM()
- COUNT()
- MEAN()
- TOTAL()
Rounding Averages
Which SQL function is used to round the average rating to exactly two decimal places?
- ROUND(AVG(rating), 2)
- AROUND(AVG(rating), 2)
- ROUNDUP(AVG(rating), 2)
- TRUNC(AVG(rating), 2)
- ROUNDING(AVG(rating), 2)
Sorting Results
To display results first by month and then by product_id, which clause and order should you write in SQL?
- ORDER BY month, product_id
- GROUP BY month, product_id
- SORT BY month, product_id
- FILTER BY month ASC, product_id ASC
- ARRANGE BY month, product_id
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?
- EXTRACT(MONTH FROM review_date) AS month
- MONTH(review_date) month
- GET_MONTH(review_date) -u003E month
- EXTRACT(MONTH, review_date) FOR month
- MONTH_OF(review_date) month
Identifying Typos in Function Names
Which of the following is the correctly spelled and formatted aggregate function to find the average?
- AVG(value)
- AVRG(value)
- AVGE(value)
- AVEG(value)
- AVRGG(value)
Aggregating with Multiple Columns
When grouping data by both month and product_id and calculating averages, how should you structure your GROUP BY clause?
- GROUP BY month, product_id
- GROUP BY month product_id
- GROUP month AND product_id
- GROUP BY (month + product_id)
- GROUPED BY product_id THEN month
Selecting and Aliasing
If calculating the rounded average of star_rating, how do you correctly alias the result as avg_star_rating?
- ROUND(AVG(star_rating), 2) AS avg_star_rating
- ROUND(AVG(star_rating), 2) avg_star_rating
- ROUND(AVG(star_rating), 2) TO avg_star_rating
- AVG(star_rating) round as avg_star_rating
- AVG(star_rating, 2) AS avg_star_rating
Order of SQL Clauses
What is the correct order for these SQL clauses in a query: SELECT, FROM, GROUP BY, ORDER BY?
- SELECT, FROM, GROUP BY, ORDER BY
- FROM, SELECT, GROUP BY, ORDER BY
- SELECT, GROUP BY, FROM, ORDER BY
- ORDER BY, SELECT, FROM, GROUP BY
- FROM, SELECT, ORDER BY, GROUP BY