~~~~~~~~~~~~求一查询语句!~~~~~~~~~~~
表结构如下
A B C
001 123 QW
001 568 SE
001 895 RE
002 785 WP
002 542 IO
003 795 QQ
003 963 PP
.........
想得到如下结果
A B C
001 123 QW
002 542 IO
003 963 PP
既A字段相同的只取一行。求一查询语句
------解决方案------------------------方法1:
select * from 表 as a where not exists(select 1 from 表 where A=a.A and b <a.b)
----方法2:
select * from 表 as a where b= (select min(b) from 表 where a= a.a)
order by a
----方法3:
select a.* from 表 as a inner join (select a,min(b) as b from 表 group by a) as b
on b.a= a.a and a.b= b.b order by a.a