oracle字符串连接函数,||使两个或多个字段拼成一个字段

select t.id, case when t.id is not null then t.work_score||t.sort end haoming from stu_workinfo t



 select t.id,
case 
  when t.id is not null 
    then concat(t.work_score,t.sort) 
      end haomingddd
 from stu_workinfo t


 
在查询时往往需要拼字符串,在程序拼是容易想到的方法,但有时很不方便, 

或者拼完以后程序又需要拼之前的字段,这样再拆字符串就很麻烦了。

用sql解决最多多出一个字段,这是你需要的,并不影响其他字段。

从这里我们还可以有其他很多品字段的方法,自己可以尝试着学习

select b.STUCODE stucodeb,b.STUDENT_NAME, case when b.STUCODE is not null then b.STUCODE||'-'||b.STUDENT_NAME end codename ,c.stucode,c.id classid from v_stu_student b, ( select * from stu_class_ref a -- where a.id='' ) c where b.STUCODE=c.stucode



select k.stucode,k.codename from
(
select b.STUCODE stucodeb,b.STUDENT_NAME,
case
when b.STUCODE is not null
then b.STUCODE||'-'||b.STUDENT_NAME
end codename
,c.stucode,c.id classid from v_stu_student b,
(
select * from stu_class_ref a
-- where a.id=''
) c
where b.STUCODE=c.stucode
) k
where k.classid='45595522:134924a9ac0:-7fee'

 

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值