-
Consider the following database table named water_schemes:
The number of tuples returned by the following SQL query is ________.
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
-
- 2
- 3
- 4
- 5
Correct Option: A
First we should perform group by group. We get ajmer 1
bikaner 3
charu 2
dungargarh 1
Now we should perform total capacity we will get 100. Now perform avg. capacity on total 100 / 4 = 25. bikaner = 40 which is greater than 25 charu is 30 which is also greater than 25. Hence charu and bikaner will be printed therefore answer is 2 tuples.