62,046
社区成员
发帖
与我相关
我的任务
分享
create table T(id int ,F1 char(1),F2 char(1),F3 Char(1))
insert into T select 1,'a','b','c'
union select 2, 'd','e','c'
union select 3, 'f','g','h'
select * from t
select * from t
where id =(select max(id) from t AS t2 where t2.f1=t.f1 or t2.f2=t.f2 or t2.f3= t.f3)
-----------------------------------------
--> 测试时间:2009-07-29
--> 我的淘宝:http://shop36766744.taobao.com/
--------------------------------------------------
if object_id('[TB]') is not null drop table [TB]
create table [TB]([列1] varchar(1),[列2] varchar(1),[列3] varchar(1))
insert [TB]
select 'a','b','c' union all
select 'd','e','c' union all
select 'f','g','h'
select * from [TB] t where not exists(select 1 from TB where T.列3=列3 and t.列1>列1)
/*
列1 列2 列3
---- ---- ----
a b c
f g h
(所影响的行数为 2 行)
*/
drop table TB
select * from 表 Where [列1] in (select max([列1]) from 表 group by [列3])
select * from 表 Where [列1] in (select max([列1])) from 表 group by [列3])
select * from 表 Where [列1] in (select max(列1)]) from 表 group by [列3])
select * from 表 Where [主键] in (select max([主键]) from 表 group by [重复字段])
http://cam.taoke.alimama.com/event.php?pid=mm_13700003_0_0&eventid=100889