以下的SQL需求如何实现,急求
0
现在有表A,字段有id和at_id,表B有字段id,表A的at_id下有各种属性值,现在要求找到表A下的相同字段id同时含有at_id的5个属性,必须满足, 比如10,11,12,13,14,15,这里应该不能用in(10,11,12,13,14,15)吧,应该如何写,麻烦开发高手指导写下,谢谢。
数据库:Oracle
数据库:Oracle
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
5 个回复
天善_小龙 2016-04-07 回答
赞同来自: 廖伟杰
select * from (with temp as(
select '100' id ,'10' at_id from dual union all
select '100' id ,'11' at_id from dual union all
select '100' id ,'12' at_id from dual union all
select '100' id ,'13' at_id from dual union all
select '100' id ,'14' at_id from dual union all
select '100' id ,'15' at_id from dual union all
select '101' id ,'10' at_id from dual union all
select '101' id ,'11' at_id from dual union all
select '101' id ,'12' at_id from dual union all
select '101' id ,'13' at_id from dual union all
select '101' id ,'14' at_id from dual union all
select '101' id ,'15' at_id from dual union all
select '102' id ,'11' at_id from dual union all
select '102' id ,'12' at_id from dual union all
select '102' id ,'13' at_id from dual union all
select '102' id ,'14' at_id from dual
)
select
id,
at_id,
listagg(at_id,',') within GROUP (order by at_id) over (partition by id) rank
from temp)a
where a.rank='10,11,12,13,14,15';
牟瑞 - 大数据 Hadoop 讲师 Hadoop入门课程地址:http://www.hellobi.com/course/39 有架构师,技术总监,CTO的职位请联系我! 2016-04-07 回答
赞同来自:
老头子 - 专注是唯一的捷径 2016-04-07 回答
赞同来自:
A表如下数据,则吧ID=1取出? AT_ID一共有几种属性?最多就6种么?
ID |AT_ID
1 |10
1 |11
1 |12
1 |13
1 |14
1 |15
2 |13
2 |14
3 |11
4 |11
4 |12
4 |13
4 |14
GeorgeYao - 路漫漫其修远兮,吾将上下而求索! 2016-04-07 回答
赞同来自:
jason_lew - 关注BI 2016-04-08 回答
赞同来自: