【问题标题】:Find distinct child rows which have more than 1 parent in the same table Oracle在同一个表 Oracle 中查找具有超过 1 个父项的不同子行
【发布时间】:2016-02-03 09:00:13
【问题描述】:

我有一个结构如下的表

我需要识别所有具有超过 1 个 0 级 id 的唯一 1 级 id 在这个例子中,查询应该返回 200, 400

我怎样才能做到这一点?


【问题讨论】:

    标签: sql oracle oracle11g


    【解决方案1】:
    select 1st_level_id
    from your_table
    group by 1st_level_id
    having count(distinct 0th_level_id) > 1
    

    【讨论】:

    • 非常感谢!!如果我​​希望 100,300 条记录集正确,我也可以执行 count(distinct 0th_level_id) = 1?
    • 是的,这将给出只有一个 0th_level_id 的记录
    猜你喜欢
    • 2021-10-06
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 1970-01-01
    • 2020-03-31
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多