sql应该怎么写???oracle数据库

image.png

select 
a.TZ||' '||a.BZ 备注一
from
(
select distinct
bmba002 bomtx, 
case when substr(bmba003,1,2) !='30' then '30'||substr(bmba003,3,10) else bmba003 end lh,
imecl005 tz,
bmbaud010 bz
from 
bmba_t 
left join bmce_t on bmce001 = bmba001 and bmce003 = bmba003 and bmce002 = bmba002 and bmbaent = bmceent and bmbasite = bmcesite
left join imecl_t on imecl003 = bmce010 and imeclent = bmceent
where bmba002 ='BO-1004-2' and bmba003 like '3%' and bmbasite = 'ALL' and bmbaud010 is not null and bmce010 is not null and bmbaud010 !='加0.25%爽滑剂' 
) a

想要的目的是最终结果把那三条记录拼接变成一条记录 最终变成  黄PP-4022 外喷砂/黄PP-4022 外喷砂/黄PP-4022 外喷砂

Jacklove 发布于 2020-4-8 13:47 (编辑于 2020-4-8 14:01)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
zsh331Lv8专家互助
发布于2020-4-8 13:55
select
to_char(wm_concat(a.TZ||' '||a.BZ 备注一)) as RW
from
(
select distinct
bmba002 bomtx, 
case when substr(bmba003,1,2) !='30' then '30'||substr(bmba003,3,10) else bmba003 end lh,
imecl005 tz,
bmbaud010 bz
from 
bmba_t 
left join bmce_t on bmce001 = bmba001 and bmce003 = bmba003 and bmce002 = bmba002 and bmbaent = bmceent and bmbasite = bmcesite
left join imecl_t on imecl003 = bmce010 and imeclent = bmceent
where bmba002 ='BO-1004-2' and bmba003 like '3%' and bmbasite = 'ALL' and bmbaud010 is not null and bmce010 is not null and bmbaud010 !='加0.25%爽滑剂' 
) a


  • Jacklove Jacklove(提问者) 提示缺失右括号 检查了一下没问题啊
    2020-04-08 14:01 
  • zsh331 zsh331 回复 Jacklove(提问者) to_char() & wm_concat() 函数的运用,你了解下~
    2020-04-08 14:02 
  • Jacklove Jacklove(提问者) 回复 zsh331 > ORA-00904: \"WM_CONCAT\": 标识符无效
    2020-04-08 14:03 
  • zsh331 zsh331 回复 Jacklove(提问者) 是oracle吧 https://www.iteye.com/blog/christy-fang-1299850 难道是版本问题,就是字段分组拼接的函数!
    2020-04-08 14:06 
  • Jacklove Jacklove(提问者) 回复 zsh331 是的 可能是版本问题 不过版本挺高的啊
    2020-04-08 14:08 
  • 2关注人数
  • 438浏览人数
  • 最后回答于:2020-4-8 14:01
    请选择关闭问题的原因
    确定 取消
    返回顶部