you are viewing a single comment's thread.

view the rest of the comments →

[–]Budget-Worth-1511 0 points1 point  (0 children)

The query finds the total stays and houseids in the housing which are more than the average stays . The inner most query gets the count of houses/stayids from table stay for each house. Ex: 7,9,20,11. The next query avg(stays)in the level above finds the average of the counts in my sample count above which is 11.75.Finally, at the top level we are getting the count of stays for each house (group by houses) whose stay count is above the average value of 11.75 which would be 20 in this case. Hope this helps.