4

good_name 列对于所有结果都是空的。查询中有什么问题?

select fp.id,
   listagg(fpg.name, ',') within group(order by fpg.name) good_name
from fp_place_goods fppg join 
   fp_places fp on fppg.place_id = fp.id join
   fp_goods fpg on fppg.good_id = fpg.id
GROUP BY fp.id

however query below works

select fp.id,
   listagg(fpg.id, ',') within group(order by fpg.id) good_ids
from fp_place_goods fppg join 
   fp_places fp on fppg.place_id = fp.id join
   fp_goods fpg on fppg.good_id = fpg.id
GROUP BY fp.id




select fp.id, fpg.name from fp_places fp join
      fp_place_goods fppg on fp.id = fppg.place_id join
      fp_goods fpg on fpg.id = fppg.good_id 

以图像形式返回结果

http://i.stack.imgur.com/Y16G3.png

4

1 回答 1

12

发生这种情况是因为 good_name 是 nvarchar,而 to_char(fpg.name) 解决了它。

于 2016-05-07T13:22:28.363 回答