select * from (
select * from (
select top 3 mdg,qsg,count(mdg) cont from HxTable
where Qsg ='青岛' group by mdg,qsg
order by count(mdg) desc)t1
union all
select * from(
select top 2 mdg,qsg,count(mdg) cont from HxTable
where Qsg ='宁波' group by mdg,qsg
order by count(mdg) desc)t2
union all
select * from (
select top 3 mdg,qsg,count(mdg) cont from HxTable
where Qsg ='上海' group by mdg,qsg
order by count(mdg) desc)t3
) as result
order by cont desc
select qsg,count(mdg),cont from(
select top 3 mdg,qsg,count(mdg) cont from HxTable
where Qsg ='青岛'
union all
select top 2 mdg,qsg,count(mdg) cont from HxTable
where Qsg ='宁波'
union all
select top 3 mdg,qsg,count(mdg) cont from HxTable
where Qsg ='上海' ) t1 group by mdg,qsg
order by count(mdg) desc
这个问题好像刚刚回答过。