【发布时间】:2021-10-07 23:33:58
【问题描述】:
我有以下疑问:
Select c.name, c.age, m.salary from customers c
left join money m on c.ID = m.ID and m.salary > 10000
where c.age > 50
现在我想获取 100 行的样本。我怎样才能做到这一点?我尝试使用 仅获取前 100 行,但这不会产生随机样本。
【问题讨论】:
我有以下疑问:
Select c.name, c.age, m.salary from customers c
left join money m on c.ID = m.ID and m.salary > 10000
where c.age > 50
现在我想获取 100 行的样本。我怎样才能做到这一点?我尝试使用 仅获取前 100 行,但这不会产生随机样本。
【问题讨论】:
您可以在获取之前进行随机排序:
Select c.name, c.age, m.salary
from customers c left join
money m
on c.ID = m.ID and m.salary > 10000
where c.age > 50
order by dbms_random.random()
fetch first 100 rows only;
【讨论】: