原始数据(图片) 我想通过连接几个列来显示我的数据。但是看起来不完美的数据:在连接结束时有一个逗号,如图所示:
这是我在oracle 10g中创建的查询
select id_pegawai,
whitelist_pembayaran||decode(whitelist_pembayaran,null,null,', ')||
whitelist_pemasang||decode(whitelist_pemasang,null,null,', ')||
whitelist_jenis_iklan||decode(whitelist_jenis_iklan,null,null) as whitelist,
blacklist_pembayaran||decode(blacklist_pembayaran,null,null,', ')||
blacklist_pemasang||decode(blacklist_pemasang,null,null,', ')||
blacklist_jenis_iklan||decode(blacklist_jenis_iklan,null,null) as blacklist
from verifikator order by id_verifikator desc
答案 0 :(得分:2)
所以你只想删除最后的逗号? RTRIM
它。
select id_pegawai,
rtrim(whitelist_pembayaran || decode(whitelist_pembayaran, null, null, ', ') ||
whitelist_pemasang || decode(whitelist_pemasang, null, null, ', ') ||
whitelist_jenis_iklan, ',') as whitelist,
rtrim(blacklist_pembayaran || decode(blacklist_pembayaran, null, null, ', ') ||
blacklist_pemasang || decode(blacklist_pemasang, null, null, ', ') ||
blacklist_jenis_iklan, ',') as blacklist
from verifikator
order by id_verifikator desc