Oracle一些常用的方法

1、取交集的是intersect

2、minus的作用简单来说是去同留异,例:select * from table where rownum<10 minus se...

3、Union不用多说,关联合并


4、

OracleSQL.oracle中length()与lengthb()区别 
SQL> select length('阿猪') from dual; 
LENGTH('阿猪') 
-------------- 
             2

SQL> select lengthb('阿猪') from dual;

LENGTHB('阿猪') 
--------------- 
              4


区别:length求得是字符长度,lengthb求得是字节长度。


5、关联查询一个希望排序的结果

Select A.BarCode,A.PluCode,A.PluName,A.PluAbbrName,A.Unit,A.Spec,
   Nvl((Select Sum(KcCount) From tStkLsKc Where OrgCode='1008' And PluId=A.PluID And PluType='0'),0) as KcCoount,
   Nvl((Select Price From tSkuPluEx Where OrgCode='1008' And PluID=A.PluId),0) as Price,
   (Select YhPrice 
      From (Select PluId,YhPrice,Row_NUmber() over(partition by OrgCode,PluId order by Pri desc) as RowNo
             From tProCxPtPlu 
            Where OrgCode='1008'
              And PosComUpType<>'2' And IsEnabled='1'
              And to_char(SysDate,'yyyy-mm-dd') Between BgnDate And EndDate  
              And to_char(SysDate,'hh24:mi:ss') between BgnTime And EndTime)
     Where PluId=A.PluID And RowNo=1 
    ) as YhPrice
From tSkuPlu A
Where A.pluid=10010000026626;


6、Oracle的loop循环中,11G之前不支持continue

解决方法有二:

法1:

goto label_name,设置标签的语法如下:
<<label_name>>
可以为循环设置标签
<<label_name>> 后面不能直接跟EXCEPTION这种关键字类的语句,要用NULL把标签跟关键字隔开。类似的关键字还有END LOOP之类的,等等
法2:

loop
     fetch c1 into c1_rec              
     EXIT WHEN c1%NOTFOUND;
     if 某个条件

     then

--模拟continue.跳到下一个循环
       null;
     else
       do something
     end if;
  end loop;



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值