declare @t table(id varchar(64),科别 varchar(64),分数 varchar(64)) insert into @t select '01','语文','79' union all select '02','语文','89' union all select '03','数学','69' union all select '04','数学','98'select * from @t a where id in(select top 1 id from @t b where a.科别=b.科别 order by 分数 desc)
这分我拿定了。谁让你们 发表的那么早,让我可以抄袭呢。。select 科目,max(分数) from 成绩表 group by 科目 order by 分数他们都没order by 。我要分。。
insert into @t
select '01','语文','79'
union all
select '02','语文','89'
union all
select '03','数学','69'
union all
select '04','数学','98'select * from @t a
where id in(select top 1 id from @t b where a.科别=b.科别 order by 分数 desc)