表:
T1
Doc ver
cd A
cd B
ee A
ee B
ee C
qq A
要求得出结果为
A B
cd B
ee C
qq A
------解决方案--------------------
select doc,max(ver) from table group by doc
------解决方案--------------------
create table tb
(
doc varchar(10),
ver varchar(20)
)
insert tb select 'cd ', 'A '
insert tb select 'cd ', 'B '
insert tb select 'ee ', 'A '
insert tb select 'ee ', 'B '
insert tb select 'ee ', 'C '
insert tb select 'qq ', 'A '
select doc,max(ver) from tb group by doc
drop table tb
-------------
结果为
cd B
ee C
qq A