问题是这样的:
有一张table表,username , cource,  为三个字段。Username   Cource   Mark
黎明     数学    90
黎明        语文    90
乐乐        数学    120 
乐乐        语文    109
乐乐        英语    100 
毛毛        语文    100 
毛毛        数学    109
               
要求写SQl语句查询总成绩大于200分的学生姓名  

解决方案 »

  1.   

    select username,sum() as s from table where s>200 group by username;
      

  2.   

    select username from table 
    (select sum() s username from table group by username) sumtable
    where table.username = sumtable.username and sumtable.s>200
      

  3.   

    select username from table having sum(Mark)>200 group by Username 
      

  4.   

    受楼上启发不知道对不对
    select username,sum() as s from table where group by username having s>200;
      

  5.   

    select username from table group by username having sum()>200
      

  6.   

    select username,sum() as s from table where group by username having s>200
      

  7.   

    select username,sum() as s from table where group by username having s>200;
      

  8.   

    引用或者参考一楼的兄弟们,你们的语句适合那种数据库??(我也认为这样正确可是mysql不认)
    目前为止:五楼是正解
      

  9.   

    select username ,sum(Mark) ss from table group by Cource having ss>200;
    没看上面的哦,不知道是不是这样!
      

  10.   

    错了group by后面应该是跟username!
      

  11.   

    SELECT Username , SUM(Mark) FROM table
    GROUP BY Username
    HAVING COUNT(Mark) >= 200;
      

  12.   

    select username,sum() as s from table where s>200 group by username; 
      

  13.   

    要写sql用标准的sql,不要使用数据库特定的:
    select username from table group by username having sum()>200
    这个适用所有数据库
    他的意思是说:首先按 username分组,再把分组的数据求和,并且>200的 人名查出来。
    这是合适sql-92标准的。
      

  14.   

    5楼正解
     select uesrname from table group by username having sum(>200                                                                                                                                     
      

  15.   

    select username,sum() as s from table where s>200 group by username