从 2 个表中获取平均值?

Getting average from 2 tables?

我需要有关 sql 命令的帮助~ 提前感谢您的帮助^^

所以我有 2 tables

我怎样才能得到这 2 个的平均值 table。

我想要的结果是

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

非常感谢!

您可以将这两个表作为 UNION ALL 查询,然后将其用作 GROUP BYFrequency 列上的 AVG() 的子查询:

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;