1

こんにちは、コードの出力表示を削除またはフォーマットする必要があるクエリがあります。下記を参照してください:

クエリ:

select rfc."NUMBER",
ag.current_pending_groups
from smspadm.cm3rm1 rfc, smspadm.tv_approval_vw appr, smspadm.approvala1 ag
Order By rfc."NUMBER"

現在の結果:

NUMBER  CURRENT_PENDING_GROUPS

C301609 Comm/AT&T Vert DCAB
C302023 Collections DCAB
C302023 Comm/AT&T Vert DCAB
C302023 Fin-D2C-DNB DCAB
C302023 Interactive Recording DCAB
C302103 Collections DCAB
C302103 Wintel Server DCAB
C302103 Fin-D2C-DNB DCAB
C301813 GTHRA Vert DCAB
C301813 Tech Vert DCAB

望ましい結果: 次のいずれか:

NUMBER  CURRENT_PENDING_GROUPS

C301609 Comm/AT&T Vert DCAB
C302023 Collections DCAB, Comm/AT&T Vert DCAB, Fin-D2C-DNB DCAB
C302103 Collections DCAB, Wintel Server DCAB, Fin-D2C-DNB DCAB
C301813 GTHRA Vert DCAB, Tech Vert DCAB

または、次のようにする必要があります。

NUMBER  CURRENT_PENDING_GROUPS

C301609 Comm/AT&T Vert DCAB
C302023 Collections DCAB
        Comm/AT&T Vert DCAB
        Fin-D2C-DNB DCAB
        Interactive Recording DCAB
C302103 Collections DCAB
        Wintel Server DCAB
        Fin-D2C-DNB DCAB
C301813 GTHRA Vert DCAB
        Tech Vert DCAB

この結果を得るには、どのクエリを使用すればよいですか?

4

2 に答える 2

1
SELECT rfc."NUMBER",
  LISTAGG(ag.current_pending_groups, ', ')
   WITHIN GROUP (ORDER BY rfc."NUMBER") "CURRENT_PENDING_GROUPS"
   FROM smspadm.cm3rm1 rfc, smspadm.tv_approval_vw appr, smspadm.approvala1 ag
   GROUP BY rfc."NUMBER";


SELECT rfc."NUMBER",
   wm_concat(ag.current_pending_groups)
   FROM smspadm.cm3rm1 rfc, smspadm.tv_approval_vw appr, smspadm.approvala1 ag
   GROUP BY rfc."NUMBER";
于 2013-03-18T18:04:34.157 に答える
0

最初のバリアント

select 
  rfc."NUMBER",
  wm_concat(ag.current_pending_groups)  -- for 10g
  -- listagg(ag.current_pending_groups,',') within group (order by ag.current_pending_groups)  -- for 11g
  as CURRENT_PENDING_GROUPS
from smspadm.cm3rm1 rfc, smspadm.tv_approval_vw appr, smspadm.approvala1 ag
group by rfc."NUMBER"
Order By rfc."NUMBER"

2 番目のバリアント

select
  case when
    row_number() over (partition by rfc."NUMBER" order by ag.current_pending_groups) = 1
  then
    rfc."NUMBER"
  end as "NUMBER",
  ag.current_pending_groups
from smspadm.cm3rm1 rfc, smspadm.tv_approval_vw appr, smspadm.approvala1 ag
Order By rfc."NUMBER", ag.current_pending_groups
于 2013-03-18T15:20:43.463 に答える