我需要sql命令方面的帮助~提前谢谢你的帮助^^所以我有两张table我怎样才能从这个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
非常感谢你!
628mspwn1#
可以将这两个表作为一个表进行查询 UNION ALL 然后用它作为子查询 GROUP BY 和一个 AVG() 上 Frequency 列:
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;
1条答案
按热度按时间628mspwn1#
可以将这两个表作为一个表进行查询
UNION ALL
然后用它作为子查询GROUP BY
和一个AVG()
上Frequency
列: