同班同名的人也可能存在的
delete from studentStore 
where id not in( 
select max(id) from studentStore group by class,student
)

解决方案 »

  1.   

    delete from studentStore 
    where id not in( 
    select max(id) from studentStore group by class,student,subject,score
    )这样?
      

  2.   


    DELETE FROM STUDENTSTORE 
    WHERE ID NOT IN( 
    SELECT MAX(ID) FROM STUDENTSTORE GROUP BY CLASS,STUDENT
    )
      

  3.   

    grouo by 后面还能加,号?这个括号内的意思是分组的最大id?感觉有点问题
      

  4.   

    1、DELETE FROM studentScore WHERE id NOT in(SELECT MIN(id)from studentScore  GROUP BY  student,`subject`,score);2、SELECT * from studentScore LIMIT  9,3;
    3、SELECT  student from studentScore WHERE score>80 GROUP BY student;
    4、SELECT SUM(a.s) from  ( (SELECT student,SUM(studentScore.score) as s FROM studentScore GROUP BY student) as a);
    SELECT student,SUM(studentScore.score) as s FROM studentScore GROUP BY student;
      

  5.   

    in或者not in可能会随着重复数据量的多少而有比较大的效率差异。
    delete from studentscore t1 
     where t1.rowid in (
       select v1.rowid from (
           select v1.rowid, 
                  row_number() over(partition by v1.class, v1.student, v1.subject, v1.score order by v1.id) rn 
             from studentscore v1
       ) vv1
       where vv1.rn > 1
     );
      

  6.   


    第三个错了
    select student 
      from studentscore t1
     group by student
    having count(1) = count(case when score > 80 then 1 else null end)
    ;
    第四个明显考的分析函数
    select t1.student, 
           sum(t1.score) over(partition by t1.student),
           sum(t1.score) over(partition by t1.class)
      from studentscore t1
     where t1.class = 1
    ;
    第一问,原题不严谨,没说按什么确定是哪个学生,不加class就不加吧。
    第二问,limit没用过,不做评论