select top 10 * from(
select top 10 num from a
union
select top 10 num from b
union
select top 10 num from c
order by num desc) --子查询
select top 10 num from a
union
select top 10 num from b
union
select top 10 num from c
order by num desc) --子查询
select top 10 num from a
union
select top 10 num from b
union
select top 10 num from c
)a --子查询
order by num desc我想要的是所有组合起来的联合表里面num最大的10个。select top 10 * from(
select num from a
union
select num from b
union
select num from c
)a --子查询
order by num desc去掉每个组合数据的top 10就可以,把a,b,c中所有的数据都出来组合一下,然后top 10 ,order by desc,但是这样做可能太浪费,效率低。我想先把每个表中num最大的10个取出来组合一下,然后再把组合的数据集
就如这样的例子:select top 10 * from(
select num from a order by num desc
union
select num from b order by num desc
union
select num from c order by num desc
)a --子查询但是union中不让用order by ...
咋办?
select top 10 num from a
union
select top 10 num from b
union
select top 10 num from c
order by num desc) --子查询这样做只是把c表order by desc了,然后组合吧?
是不是啊,各位老大?
(select top 10 num from a order by num)
union
(select top 10 num from b order by num)
union
(select top 10 num from c order by num)
select num from a
union
select num from b
union
select num from c
)a --子查询
order by num desc