1 小红 语文 67
2 小红 数学 45
3 小红 英语 87
4 小张 语文 98
5 小张 数学 55
6 小张 英语 45
7 小李 语文 34
8 小李 数学 64
9 小李 英语 72
查询出的结果
4 小张 语文 98
8 小李 数学 64
3 小红 英语 87谢谢各位帮忙!在线等,立马给分!

解决方案 »

  1.   

    select ID ,Name,課程 max(分數)from tb group by ID ,Name,課程
      

  2.   

    select t.* from 表 t where not exists(select 1 from 表 where 科目=t.科目 and 成绩>t.成绩)
      

  3.   

    select ID ,Name,課程 max(分數)from tb group by ID ,Name,課程
      

  4.   

    select * from tb t where 成绩 = (select max(成绩) from tb where 科目 = t.科目)
      

  5.   

    select * from tb where not exists(select 1 from tb b where checksum(tb.姓名,tb.课程)=checksum(b.姓名,b.课程) and tb.成绩<b.成绩)
      

  6.   


    select a.* from tb a 
    join (select 科目,max(成绩) from tb group by 科目) b
    on a.科目=b.科目 and a.成绩=b.成绩
      

  7.   


    --5楼的有问题
    select * from tb 
    where not exists(select 1 from tb b where tb.课程=b.课程 and tb.成绩 <b.成绩)
      

  8.   

    结果都不对!以上的代码我都测试没有一个完成了!我想要每一科目的最高分的信息!列名对应: id    name   kemu  score各位大侠加油!!在线等!!立刻给分!
      

  9.   

    select B.* from 表名 as B,(select 科目 as 科目,max(分数) as 分数 from 表名 group by 科目) A    where A.科目=B.科目 and A.分数 = B.分数
      

  10.   

    1
    select t.* from 表 t where not exists(select 1 from 表 where 科目=t.科目 and 成绩>t.成绩)
    2
    select ID ,Name,課程 max(分數)from tb group by ID ,Name,課程
      

  11.   

    select t.* from 表 t where not exists(select 1 from 表 where 科目=t.科目 and Name=t.Name and 成绩>t.成绩)
    2
    select ID ,Name,課程 max(分數)from tb group by ID ,Name,課程
      

  12.   

    此贴已结!!谢谢!!!正确代码:
    create table tb(id int,name varchar(20),kemu varchar(20),score int)
    go
    insert into tb select 1,'小红','语文',67
    insert into tb select 2,'小红','数学',45
    insert into tb select 3,'小红','英语',87
    insert into tb select 4,'小张','语文',98
    insert into tb select 5,'小张','数学',55
    insert into tb select 6,'小张','英语',45
    insert into tb select 7,'小李','语文',34
    insert into tb select 8,'小李','数学',64
    insert into tb select 9,'小李','英语',72 
    go
    select * from tb;
    select * from tb where not exists(select 1 from tb b where tb.kemu=b.kemu and tb.score<b.score);
    go
    drop table tb;
    gO
      

  13.   

    看错料1
    这个应该可以啊 select t.* from 表 t where not exists(select 1 from 表 where 科目=t.科目 and 成绩>t.成绩)还有可以利用CHECK什么的也可以
      

  14.   

    select t.*
    from course t join 
    (select coursename,max(chengji) as l from course  group by coursename) u 
    on u.coursename=t.coursename and t.chengji=u.l
      

  15.   

    select B.* from tb as B right join (select item,max(score) as score from tb group by item) A  on A.item=B.item and A.score = B.score