A university stores course enrolments in the table enrolments below, where a NULL grade means the grade has not yet been recorded.
enrol_id
student_id
course
grade
1
101
DB
78
2
102
NULL
3
OS
85
4
103
5
6
104
91
The query SELECT COUNT(*), COUNT(grade), COUNT(DISTINCT student_id), COUNT(DISTINCT grade) FROM enrolments; is run. Enter each result as a whole number. COUNT(*) returns , COUNT(grade) returns , COUNT(DISTINCT student_id) returns , and COUNT(DISTINCT grade) returns .
Unlock full course notes by signing up
AVG with NULL ratings
A table reviews stores product ratings in a NUMERIC column rating; a rating is NULL when the reviewer left a comment but no score.
What value does SELECT AVG(rating) FROM reviews WHERE product_id = 7; return? Give your answer to two decimal places.
Tracing WHERE and HAVING together
A table sales records individual sales in dollars:
The following query is run:
How many rows does the query return, and what are the highest and lowest values of big_total among the returned rows? Give each answer as a whole number, with the totals in dollars.
Interpreting a HAVING clause with a subquery
A table employees(emp_id, dept, salary, hire_year) holds one row per employee. Consider this query:
Which of the following statements about this query are true? Select all that apply.
Grouping by two columns with a HAVING filter
A retailer records sales in the table orders below. A NULL amount marks an order whose payment has not yet been captured. Amounts are in whole dollars.
Give, as whole numbers, the number of groups that GROUP BY forms before HAVING is applied, the number of rows the query returns, the value of total in the first result row in dollars, and the value of total in the last result row in dollars.