【发布时间】:2021-03-08 11:59:14
【问题描述】:
目前,我有一个 CTE,它正在构建一个数据列表和一个随机行号
我想要做的是根据一些标准输出几个联合在一起的查询。查询可以与联合一起正常工作,但当我为任何查询添加限制时将无法正常工作。
有没有一种方法可以运行查询并获取不同的子集?
例子:
with selection as (
select account, address, type, random(1000)
from details
)
select
account,
address
from details
where type = 'a'
order by random
limit 50
union all
select
account,
address
from details
where type = 'b'
order by random
limit 50
union all
select
account,
address
from details
where type = 'c'
order by random
limit 50
【问题讨论】:
-
请注意,
selection未使用。