数据库:Oracle 表数据如下:
gx1 gx2 gx3 gx4
------------------------
a1 a2 null null
b1 null null null
c1 c2 c3 null
d1 null null null
.
.
.
求结果
gx
-------
a1/a2
b1
c1/c2/c3
d1
问题:将四个字段的值合并为一个字段,并用'/'隔开,如果直接用gx1||'/'gx2||'/'||gx3||'/'||gx4会出现这样的结果
gx
--------
a1/a2//
b1///
c1/c2/c3/
d1///
但是我要的结果是: gx
-------
a1/a2
b1
c1/c2/c3
d1
先谢大家了,顶有分!速度结贴!
gx1 gx2 gx3 gx4
------------------------
a1 a2 null null
b1 null null null
c1 c2 c3 null
d1 null null null
.
.
.
求结果
gx
-------
a1/a2
b1
c1/c2/c3
d1
问题:将四个字段的值合并为一个字段,并用'/'隔开,如果直接用gx1||'/'gx2||'/'||gx3||'/'||gx4会出现这样的结果
gx
--------
a1/a2//
b1///
c1/c2/c3/
d1///
但是我要的结果是: gx
-------
a1/a2
b1
c1/c2/c3
d1
先谢大家了,顶有分!速度结贴!
解决方案 »
- external dbid length 120 is greater than maximum (16) 什么原因?
- javaMail包loadjava到ora9i报错
- sql语句求助 要换成用where语句搞定
- 数据不是很大,检索那么慢。请给优化下。100分
- 简单的SQL问题
- oracle 修改字段属性
- 两个库AB,使用实体化视图同步数据A->B。问题1:A重启后,B的更新job失效;问题2:B的更新间隔设为每分钟1次,会产生什么问题?
- 急急!!!!!!!!!!!,在delphi 如何调用??
- 请大家给推荐本用VC对Oracle编程的书……
- pl/sql的问题
- 求一SQL语句,在线等
- 统计报表问题
from a
|| decode(t.gx1, null, '', '/' || t.gx1)
|| decode(t.gx2, null, '', '/' || t.gx2)
|| decode(t.gx3, null, '', '/' || t.gx3)
|| decode(t.gx4, null, '', '/' || t.gx4)
from table t
select
decode(t.gx1, null, '',t.gx1 || '/')
|| decode(t.gx2, null, '',t.gx2 || '/')
|| decode(t.gx3, null, '',t.gx3 || '/')
|| t.gx4
from table t
decode(t.gx1, null, '',t.gx1)|| '/'
|| decode(t.gx2, null, '',t.gx2)|| '/'
|| decode(t.gx3, null, '',t.gx3)|| '/'
|| t.gx4
from table t其实直接下面这样应该就可以了
select t.gx1 || '/' || t.gx2 || '/' || t.gx3 || '/' || t.gx4 from table t