1、oracle函数minus的作用简单来说就是“去同留异”
select ord.member_id
from wltdata.wlt_order_info ord, wltdata.wlt_sub_order_info sub
where ord.id_wlt_order_info = sub.wlt_order_info_id
and ord.created_date >= sysdate - 2
and rownum <= 10
--order by 1
minus
select ord.member_id
from wltdata.wlt_order_info ord, wltdata.wlt_sub_order_info sub
where ord.id_wlt_order_info = sub.wlt_order_info_id
and ord.created_date >= sysdate - 1
and rownum = 10
--order by 1
注意:1、放开 order by 报:ORA-00933: SQL 命令未正确结束;2、rownum 表示:伪列 ,每个表都有伪列。
2、oracle函数intersect的作用“取交集”用法同上。
3、union表示“并”,当用得时候,系统会自动将重复的元组去掉,如果想保留重复元组则就用union all
本文详细介绍了 Oracle SQL 中的集合操作符 minus、intersect 和 union 的使用方法及注意事项,通过具体示例展示了如何利用这些操作符来实现数据的去同留异、取交集和并集等功能。
486

被折叠的 条评论
为什么被折叠?



