I am new to SQL, and I would really like to help solve this rather simple problem.
select comp_table.*
from (select column_1,avg(column_2) as "avg"
from table_1, group by column_1) comp_table
→ returns the correct entries with two columns named column_1andavg
But if I go to:
select comp_table.avg
from (select column_1,avg(column_2) as "avg"
from table_1, group by column_1) comp_table
→ returns Error: invalid identifier "avg"
The thing is, I only need to select a column avg, so I cannot do it select comp_table.*. Can you guys help?
Also, if you can kindly provide some tips on customizing your query, that would be awesome.
source
share