select max(FD3) from table_name group by FD1 order by FD1
select FD1 ,FD2 ,FD3 from table_name where FD3 in ( select max(FD3) from table_name group by FD1)
上一个有点问题: select FD1 ,FD2 ,FD3 from table_name where (FD1,FD3) in ( select FD1,max(FD3) from table_name group by FD1)
SELECT FD1, FD2, FD3 FROM table_name t1 WHERE FD3 = (SELECT MAX(FD3) FROM table_name t2 WHERE t1.FD1 = t2.FD1)
select t1.* from tablename t1 ,(select FD1,max(FD3) as FD3 from tablename group by FD1) as t2 where t1.FD1=t2.FD1 and t1.FD3=t2.FD3 order by t1.FD1,t1.FD2,t1.FD3
steedhorse(晨星) 的做法不推荐 ,效率很低 。
select test1.* from test1 where fd3 in( select max(fd3) from test1 group by fd1)
,FD2
,FD3
from table_name
where FD3 in
( select max(FD3) from table_name group by FD1)
select FD1
,FD2
,FD3
from table_name
where (FD1,FD3) in
( select FD1,max(FD3) from table_name group by FD1)
FROM table_name t1
WHERE FD3 = (SELECT MAX(FD3) FROM table_name t2 WHERE t1.FD1 = t2.FD1)
order by t1.FD1,t1.FD2,t1.FD3
select test1.* from test1 where fd3 in( select max(fd3) from test1 group by fd1)