日期:2014-05-17 浏览次数:20579 次
select * from table where id in (select min(分数) from table group by 班级)
select A.*
from table_name as A
where not exists(select 1 from table_name as B where A.banji=B.banji and B.defen>A.defen)
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-09-23 11:34:10
-- Version:
-- Microsoft SQL Server 2014 (CTP1) - 11.0.9120.5 (X64)
-- Jun 10 2013 20:09:10
-- Copyright (c) Microsoft Corporation
-- Enterprise Evaluation Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------
--> 测试数据:[huang]
if object_id('[huang]') is not null drop table [huang]
go
create table [huang]([ID] int,[班级] varchar(4),[名称] varchar(4),[得分] int)
insert [huang]
select 1,'一班','张三',90 union all
select 2,'一班','李四',91 union all