考虑以下名为 water_schemes 的数据库表:
以下 SQL 查询返回的元组数为
with total(name, capacity) as
select district_name, sum(capacity)
from water_schemes
group by district_name
with total_avg(capacity) as
select avg(capacity)
from total
select name
from total, total_avg
where total.capacity >= total_avg.capacity
(一) 1
(乙) 2
(三) 3
(四) 4答案:(乙)
说明:按区名进行第一组,得到的总容量如下
Ajmer 20
Bikaner 40
Charu 30
Dungargarh 10
然后计算平均容量,
Average Capacity = (20 + 40 + 30 + 10)/4
= 100/4
= 25.
最后选择超过平均水平的地区。
Bikaner is 40 which is greater than average (25)
Charu is 30 which is also greater than average (25).
Therefore answer is 2 tuples.
这个问题的测验