你这样试试。
select * from (select top 3 * from chk1
order by cnt desc)a
union
select * from (
select top 3 * from chk2
order by cnt desc)b
select * from (select top 3 * from chk1
order by cnt desc)a
union
select * from (
select top 3 * from chk2
order by cnt desc)b
你借助臨時表吧:create table #a(...)
insert into #a...
select top 3 * from chk1
order by cnt descinsert into #a...
select top 3 * from chk2
order by cnt descselect * from #adrop table #a
order by cnt desc)
union all
select top 3 * from chk2
order by cnt desc
order by cnt desc) c
union all
select top 3 * from chk2
order by cnt desc这个是可以的
select top 3 * from (
select * from chk1
union
select * from chk2) t
order by t.cnt desc
你的办法不对,结果是:
4 1 5
1 1 4
2 2 4
你的办法我试过,好用是好用,不过在记录集里取不到结果