1

原始数据(图像) 在此处输入图像描述 我想通过连接几列来显示我的数据。但是看起来不太完美的数据:在连接的末尾有一个逗号,如图所示:

http://i1207.photobucket.com/albums/bb476/daniwarrior/decode1.jpg

这是我在 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
4

1 回答 1

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
于 2012-11-08T08:18:57.070 回答