rownum函数、union并集、intersect交集、minus差集

网友投稿 607 2022-10-08

rownum函数、union并集、intersect交集、minus差集

rownum函数、union并集、intersect交集、minus差集

rownum: 1、虚拟的,查询的时候才虚拟出来的。表中实际不存在。

2、一般不能直接写>,只能直接写<

3、通过子查询,可以使用>

select rownum,empno,ename from emp where rownum <5 order by empno;

select b ,empno ,ename from (select rownum b,emp.* from emp) a where a.b>5 and a.b<10;

union:并集,去重

select * from (select * from emp where sal<1000 union   select * from emp where sal <=2000)a order by empno;

union all:并集不去重

select * from (select * from emp where sal<1000 union all select * from emp where sal <=2000)a order by empno;

intersect:交集

select * from (select * from emp where sal<1000 intersect select * from emp where sal <=2000)a order by empno;

minus :差集

select * from (select * from emp where sal<2000 minus select * from emp where sal <=1000)a order by empno;

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Socket.IO- 实时应用程序框架(socketio python)
下一篇:SpringBoot整合ES高级查询方式
相关文章

 发表评论

暂时没有评论,来抢沙发吧~