select a , b ,c ,d from test where b > 100 group by d;
这个语句为什么提示错误呢? 请帮帮忙

解决方案 »

  1.   

    select a , b ,c ,d from test where b > 100 group by a,b,c,d;
    或者
    select max(a) , max(b) ,max(c) ,d from test where b > 100 group by d;
      

  2.   

       自己去看错误提示;
        聪明点多的也知道 如果存在d列相同数据 你的A,B,C的数据取哪个值?这不是让数据库为难吗?
      

  3.   

    1L和2L已经说了,3L也说了。。
      

  4.   

    SELECT后的字段中,如果该字段不在GROUP表达式后面,必须使用组(聚合)函数,如MIN,MAX,COUNT,SUM等
      

  5.   

    对于select中的列,如果使用了group by 子句,则这些列必须包含在group by  中,否则要以聚合函数的方式出现。
    你这个例子中,假定对c 求和,则使用sum(c),c列可以不用跟在group by 后后面,其他的都需要
    select a , b ,c ,d from test where b > 100 group by d; 改成
    select a , b ,sum(c) ,d from test where b > 100 group by a,b,d;