如何使用mysql查找平均值?

时间:2017-10-12 03:50:54

标签: mysql

我有这样的数据

    +-------------+-------+
    | countryCode | label |
    +-------------+-------+
    | KM          | A     | 
    +-------------+-------+
    | AD          | A     | 
    +-------------+-------+
    | TH          | B     |
    +-------------+-------+
    | KM          | B     |
    +-------------+-------+

如何找到像这样的平均数

    +-------------+-----+-----+-------+
    | countryCode | A   | B   | count |
    +-------------+-----+-----+-------+
    | KM          | 0.5 | 0.5 | 2     |
    +-------------+-----+-----+-------+
    | AD          | 1   | 0   | 1     |
    +-------------+-----+-----+-------+
    | TH          | 0   | 1   | 1     |
    +-------------+-----+-----+-------+

1 个答案:

答案 0 :(得分:0)

你走了。

$(document).on('click',function(){
    if (window.opener != null && !window.opener.closed){
      var val=$('#name').val();
      $('#search').val(val);
 }
 window.close();
}); 

你可以弄清楚其余部分。