0

機能に問題がありLISTAGGます。エラーORA-00937: not a single group functionが発生し続けます。このエラーをグーグルで検索しましたが、何が問題なのかまだはっきりしていません。

シナリオ: セグメントのテーブルがあります。セグメントには複数の人を割り当てることができます (1 対多)。1 つの列にセグメント番号を表示し、もう 1 つの列にユーザーのリストを表示するには、出力/レポートが必要です。

クエリ:

    select fcs.nld_flood_control_segment_id
         , fcs.fc_segment_name
         , fcs.fc_segment_abbrev_name
         , LISTAGG(ps.first_name|| ' ' ||ps.last_name, ', ') within group (ORDER BY fcs.nld_flood_control_segment_id, ps.last_name) "ListOfReps"
      from nld_flood_control_segments   fcs
         , nld_fc_segment_person_xref   xr
         , persons                      ps
     where fcs.nld_flood_control_segment_id = :P1_id
       and :P1_id                           = xr.nld_flood_control_segment_id 
       and xr.person_id                     = ps.person_id
  order by nld_flood_control_segment_id asc
         ;

どんな助けでも大歓迎です。前もって感謝します。

4

1 に答える 1

2

LISTAGG 関数の構文構造は次のとおりです。

LISTAGG( [,]) WITHIN GROUP (ORDER BY ) [OVER (PARTITION BY )]

LISTAGG は、オプションで分析として使用できる集計関数です (つまり、オプションの OVER() 句)。次の要素は必須です。

the column or expression to be aggregated;
the WITHIN GROUP keywords;
the ORDER BY clause within the grouping.

例:

LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees

以下を試して、必要なものが提供されるかどうかを確認してください。

LISTAGG(ps.first_name|| ' ' ||ps.last_name, ',') within group (ORDER BY ps.first_name|| ' ' ||ps.last_name) "ListOfReps"
于 2013-08-02T15:10:03.230 に答える