oracle的max()、full join和declare

网友投稿 641 2022-09-29

oracle的max()、full join和declare

oracle的max()、full join和declare

这是近期的一些小心得,它们之间没啥关系,统一做个记录而已。

一、max()

select * from table where ...

假如过滤条件不满足的话,返回的记录数为0. 但是,如果是

select max(...) from table where ...

过滤条件不满足,照样返回一条记录,max(…) is null 所以,如果是

insert into table1(...) select max(...) from table2 where ...

必有记录插入, ​​sql%rowcount​​ 必定大于0,有时会导致一些逻辑上的错误。

解决办法是再select 多一次,将max(…)作为过滤条件,is null则过滤掉。

二、full join 左连接,left outer join,简写为left join 右连接,right join 全连接,full join,呵呵

三、declare 直接给代码,注意end后一定要带分号​​​;​​

declare new_time date := null;beginwhile new_time is null select max(create_time) into new_time from hy_data_handle_record where create_time>to_date('2017/8/28 13:48:33','yyyy/MM/dd hh24:mi:ss');endend;

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

上一篇:有关窗口的几个操作
下一篇:小程序可以绑定服务号吗
相关文章

 发表评论

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