Sum of all rows
-
Hi all, Please have a look at the following query.
select avg(family_income) as income
from family_income
where income_type = 1 and sample_id = 10 group by family_income_name_idfamily_income table has income details with different types. Through group by I can find the average of different types. Now I want to add all the averages. sum(...) doesn't work for me. Any comments really appreciate. thanks
I appreciate your help all the time... CodingLover :)
-
Hi all, Please have a look at the following query.
select avg(family_income) as income
from family_income
where income_type = 1 and sample_id = 10 group by family_income_name_idfamily_income table has income details with different types. Through group by I can find the average of different types. Now I want to add all the averages. sum(...) doesn't work for me. Any comments really appreciate. thanks
I appreciate your help all the time... CodingLover :)
if you want to add all the averages without grouping can you simply use an inline view:
select sum(iv.income)
from (
select avg(family_income) as income
from family_income
where income_type = 1
and sample_id = 10
group by family_income_name_id) ivThe need to optimize rises from a bad design.My articles[^]
-
if you want to add all the averages without grouping can you simply use an inline view:
select sum(iv.income)
from (
select avg(family_income) as income
from family_income
where income_type = 1
and sample_id = 10
group by family_income_name_id) ivThe need to optimize rises from a bad design.My articles[^]
Thanks a lot. It works fine as I expected. I'm not clever with views in SQL. Could you have any articles written by your related to views?
I appreciate your help all the time... CodingLover :)
-
Thanks a lot. It works fine as I expected. I'm not clever with views in SQL. Could you have any articles written by your related to views?
I appreciate your help all the time... CodingLover :)
CodingLover wrote:
Thanks a lot. It works fine as I expected
No problem.
CodingLover wrote:
Could you have any articles written by your related to views?
Good idea, perhaps someday I'll contribute an article touching this subject.
The need to optimize rises from a bad design.My articles[^]
-
CodingLover wrote:
Thanks a lot. It works fine as I expected
No problem.
CodingLover wrote:
Could you have any articles written by your related to views?
Good idea, perhaps someday I'll contribute an article touching this subject.
The need to optimize rises from a bad design.My articles[^]
Mika Wendelius wrote:
Good idea, perhaps someday I'll contribute an article touching this subject.
Yeah. If I learn the stuff correctly, I'll give a try too. :)
I appreciate your help all the time... CodingLover :)