常用oracle 函数

1.oracle的 substr函数的用法:
 取得字符串中指定起始位置和长度的字符串   substr( string, start_position, [ length ] )。
例:substr('This is a test',  62)     would  return 'is'
     substr('This is a test',  6)     would  return 'is a test'
      substr('TechOnTheNet',  - 33)     would  return 'Net'
2.将Oracle中同一列的多行记录拼接成一个字符串
wm_concat函数:
select wm_concat(space_full_name) from ZD_TOBACCO_STORAGE_SPACE where TOBACCO_ID =' ' group by TOBACCO_ID
需要 排序时:
select ssd.tobacco_id,max(r) from
(select ssd0.space_code,ssd0.tobacco_id, wm_concat(ssd0.space_name)
over (partition by ssd0.tobacco_id order by to_number(ssd0.space_code)) r
from zd_tobacco_storage_space_detai ssd0)ssd
group by ssd.tobacco_id
3.查询不包含汉字的( like '%\%' 是包含 ,not like 不包含)
where asciistr(t.tobacco_code) not like '%\%'
4.查询每条数据当天最后一条
select wh.unit_id,
wh.client_id,
wh.client_name,
wh.large_address_id,
wh.large_address_name,
wh.tobacco_type,
wh.tobacco_state,
wh.tobacco_number,wh.tobacco_weight,wh.change_time,
row_number() over( partition by wh.tobacco_id order by wh.change_time desc) rn
根据wh.tobacco_id group by再根据wh.change_time时间倒序查,该分组rn从1开始
from view_TobaccoReceive_Record wh
5.四舍五入
round(to_number(sum(b.AFWEI))/to_number(decode(sum(b.BFWEI),0,1,sum(b.BFWEI))),5)
6.类似于三目运算
decode(sum(b.BFWEI),0,1,sum(b.BFWEI))
当sum(b.BFWEI)=0时,取值为1,当sum(b.BFWEI)!=0时,取值sum(b.BFWEI)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值