【问题标题】:How to get a sample in Oracle SQL [duplicate]如何在 Oracle SQL 中获取示例 [重复]
【发布时间】: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 行,但这不会产生随机样本。

【问题讨论】:

    标签: sql oracle sample


    【解决方案1】:

    您可以在获取之前进行随机排序:

    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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 2021-02-03
      • 1970-01-01
      • 2017-02-17
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      相关资源
      最近更新 更多