select * from table where a1>a and a1=(select max(a1) from table)不知我理解的对不
select * from table where al =( select max(al) as al from table) order by a
加一个ID字段做标识select * from table where ID in (select max(id) from table group by a)
我理解错了。select * from table a, (select A,max(A1) as A1 from table group by A) as b where a.A = b.A and a.A1 = b.A1
不用那么复杂吧select * from table where a+a1 in(select a+max(a1) from table group by a)如果a或a1是INI还要转成字符型
chinaiti(小心): 这个方法我也想过:)有BUG的。 比方说: A A1 1 22 12 2 这两条记录就会搞混。 改成这样吧: select * from table where cast(a as varchar(10))+'_'+cast(a1 as varchar(10)) in(select cast(a as varchar(10))+'_'+cast(max(a1) as varchar(10)) from table group by a)
其實只要一句就要可以了 select A,max(A1) from table group by A
from table
where a1>a and a1=(select max(a1) from table)不知我理解的对不
select max(al) as al from table)
order by a
(select A,max(A1) as A1 from table group by A) as b
where a.A = b.A and a.A1 = b.A1
比方说:
A A1
1 22
12 2
这两条记录就会搞混。
改成这样吧:
select *
from table where cast(a as varchar(10))+'_'+cast(a1 as varchar(10))
in(select cast(a as varchar(10))+'_'+cast(max(a1) as varchar(10))
from table group by a)
select A,max(A1) from table group by A