我需要帮助sql命令〜 感谢您的帮助^^
所以我有2张桌子
如何从这2张表中获得平均值。
我想要的结果是
Country Code 65 has 49.5 Frequency
Country Code 42 has 17 Frequency
Country Code 33 has 18 Frequency
Country Code 11 has 5 Frequency
非常感谢!
答案 0 :(得分:1)
您可以将这两个表作为UNION ALL
进行查询,然后将其用作GROUP BY
列上AVG()
和Frequency
的子查询:
select cntry_cde, Avg(freq) as freq_avg
from
(
select t1.cntry_cde, t1.freq
from avg_call t1
union all
select t2.cntry_cde, t2.freq
from calls_at_one t2
)
group by cntry_cde;