去除重复的数据.
select * from
(
select* from a
union all
select * from b
)temp
group by id,name,age
having count(*)=1
record
-----------------------
id name age
1aa22
1aa33
8hh44
8oo44
9ii44
9ll44
10jj44
我想得到这样的结果应该加什么条件呀?主要是要那个name,但不要重复的.
record
-------------
id name
1aa
8hh
8oo
9ii
9ll
10jj
先谢谢了!
[解决办法]
select id,name from tablename where age in(select max(age) from tablename group by name)
[解决办法]
max--放错位置了
select * from 表A as B
where age=(select max(age) from 表A where id =b.id and name=b.name)--保留大的