mm上送分取最大值?
表student
STUDENTID 姓名 分
1 A 92
2 A 94
3 B 98
4 B 99
5 C 98
以姓名分要取出分最大值的所有!
[解决办法]
select *
from 表名 AS t
where 分 = (select max(分) from 表名 where 姓名=T.姓名)
[解决办法]
select a.* from tb a,
(select 姓名, max(分) as 分数 group by 姓名) b
where a.姓名=b.姓名 and a.分数=b.分数
[解决办法]
declare @tab table (id int, 姓名 varchar(100), 分数 int)
insert into @tab
select 1, 'A ',92 union all
select 2, 'A ',94 union all
select 3, 'B ',98 union all
select 4, 'B ',99 union all
select 5, 'C ',98
Select * From @tab t Where 分数 In (Select max(分数) From @tab b Where b.姓名 = t.姓名)
(所影响的行数为 5 行)
id 姓名 分数
----------- ---------------------------------------------------------------- -----------
5 C 98
4 B 99
2 A 94