表:學號  姓名   成績  時間
1      a       55   2004
2      b       85   2005
.....查出成績最高的,如果成績最高有多個,找出時間最近的那一個.

解决方案 »

  1.   

    select * from table order by 成绩,时间拿第一条
      

  2.   

    select max(a.成绩)
    from 
    (select  成绩,max(时间)  as  时间
    from 表名
    group by  成绩) a
      

  3.   

    select * from table order by 成绩 desc,时间desc
      

  4.   

    order by 成绩,时间
      

  5.   

    我在ORACLE里面试的:
    select max(成绩) as MaxChenji, max(时间) as MaxShijian
    from TabName如果最高成绩相同的记录中,时间最近的也有多个,应该会一并全部查出。
      

  6.   

    select max(成績)as 最高成績,max(時間)as 最近時間 from table
      

  7.   

    select max(成績)as 最高成績,max(時間)as 最近時間 from table老大们,你们这样来做,这个时间和成绩还是对应关系的么?这会产生不正确的结果。
      

  8.   

    select * from table order by 成绩 desc,时间desc正解select max(a.成绩)
    from 
    (select  成绩,max(时间)  as  时间
    from 表名
    group by  成绩) a正解
      

  9.   

    select top 1 from table order by 成绩 desc,时间desc
      

  10.   

    select * from table order by 成绩 desc,时间descselect max(a.成绩)
    from 
    (select  成绩,max(时间)  as  时间
    from 表名
    group by  成绩) a
      

  11.   

    select * from table order by 成绩 desc,时间desc在顶一次
      

  12.   

    select top 1 * from table order by 成绩 desc,时间desc
      

  13.   

    select top 1 * from table order by 成绩 desc,时间desc 是正解。
      

  14.   

    select max(a.成绩)
    from 
    (select  成绩,max(时间)  as  时间
    from 表名
    group by  成绩) a这种方法只得到了一个成绩字段,而是那一个学生考出来的不知道.
      

  15.   

    select top 1 * from table order by 成绩 desc,时间desc  
    这个查询速度最快,