sql 语句问题
select ming,[time] from
(
select distinct ming,max([time]) as [time] from
(select distinct ming,max([time]) as [time] from a group by ming
union select distinct ming,max([time]) as [time] from b group by ming) table3
group by ming
) table4
order by [time] desc
上面这个语句是把重复的记录过滤掉,只显示ming的内容。
可现在我还要显示其它的字段aaa,bbb,ccc
如果我写成下面的语句,就不会过滤重复的记录,而是显示包括重复的记录,怎么改才能既过滤重复的记录,又能同时取出ming,aaa,bbb,ccc 这些字段?
select ming,[time] from
(
select distinct ming,max([time]) as [time] from
(select distinct ming,max([time]) as [time] from a group by ming
union select distinct ming,max([time]) as [time] from b group by ming) table3
group by ming
) table4
order by [time] desc