select a,b,c from test group by a,b
如果這樣寫,會提示c沒有包含在group by 裏面請問,如果不想把 c 也 Group by ,應該怎樣寫

解决方案 »

  1.   

    select a,b,max(c) as c  from test group by a,b
      

  2.   


    select a,b,max(c) as c    -- min()  sum()   avg()   count()  ... 要聚合
    from test group by a,b
      

  3.   

    select A,b,MIN(c) from test Group by A,b
      

  4.   

    如果你不想c group by的话 就去掉c也行select a,b from test group by a,b;
    如果你不想在group by后面C的话  在select 用函数即可
      

  5.   

    select A.学号,A.性别,B.姓名
    from(
    select 学号,性别 from 学生信息 group by 学号,性别)  A
    left join 学生信息 B ON A.学号=B.学号