日期:2014-05-17  浏览次数:20531 次

求查询出最小成绩的sql语句
请教各位师兄:

表名称:成绩表

字段有:     学号            成绩
数据如下:
            20110001          55
            20110002          45
            20110002          85
            20110003          35
            20110003          65
            20110003          89

请教如何写查询得到如下数据:
            20110001          55
            20110002          45
            20110003          35

也就是把表中所有“学号”的最低成绩找出来(一个“学号”只一条记录时就是它本身,有多条记录时找出“成绩”最小的)。
      
------最佳解决方案--------------------
select   学号,min( 成绩)成绩
from 成绩表
group by 学号
------其他解决方案--------------------
没想到这么简单,谢谢这位师兄。
------其他解决方案--------------------


create table #test
(
xuehao nvarchar(100),
chengji int
)
insert into #test
select '20110001',55 union all
select '20110002',45 union all
select '20110002',85 union all
select '20110003',35 union all
select '20110003',65 union all
select '20110003',89

select * from #test

select xuehao,min(chengji) chengji from #test group by xuehao