0

How having clause works ?

https://code.sololearn.com/W7lgOjB9mlSN/?ref=app I can understand until the group by clause. But I am not able to understand how the having clause is working in this scenario ? How are they comparing having 1 < something ?

24th Dec 2022, 6:29 AM
Levi
Levi - avatar
3 Answers
+ 3
(SELECT count(*) FROM uberdrivers U2 WHERE U.rating = U2.rating) This subquery counts the number of rows in the uberdrivers table where the rating is the same as the rating of the current row being evaluated in the outer query. The HAVING clause then compares this count to 1 and only includes rows where the count is greater than 1.
24th Dec 2022, 9:12 AM
CalviŐ˛
CalviŐ˛ - avatar
+ 1
Select the rating and average risk of all Uber drivers who have a risk score greater than or equal to 18, and group the results by rating. The HAVING clause in the query filters the results to include only those ratings where there is more than one Uber driver with that rating.
24th Dec 2022, 8:39 AM
CalviŐ˛
CalviŐ˛ - avatar
0
CalviŐ˛ what will be the output for the select inside having clause
24th Dec 2022, 8:48 AM
Levi
Levi - avatar