1

データ セットから 1 つの列を表示しようとしていますが、1 つの行に広がっています。例えば:

[Row1] [Row2] [Row3]
[Row4] [Row5] [Row6]

それ以外の:

[Row1]
[Row2]
[Row3] etc.

データセットは、外部テーブルの列に基づいて別のテーブルと結合する必要があります。つまり、データセットパラメーターを使用できないため、クロスタブは問題外です。1 つのデータ セットに含まれる行数に制限はありませんが、1 行に 3 行の列が必要です。

データセットクエリを変更できますが、これらのクエリでは、一時テーブルの作成やサーバー側で「新しい」ものを作成する場合を除いて、単純な古い SQL しか使用できません。ただし、BIRT のみのソリューションがより望ましいでしょう。

4

1 に答える 1

1

クエリを出力に変更できる場合

1 1 [Row1]
1 2 [Row2]
1 3 [Row3]
2 1 [Row4]
2 2 [Row5]
2 3 [Row6]

一時テーブルtmpに、次のようなものを使用してクエリを実行できます

select col1, col3 from tmp into tmp1 where col2 = 1;
select col1, col3 from tmp into tmp2 where col2 = 2;
select col1, col3 from tmp into tmp3 where col2 = 3;
select tmp1.col3, tmp2.col3, tmp3.col3 from tmp1, tmp2, tmp3 where tmp1.col1 = tmp2.col1 and tmp1.col1 = tmp3.col1;

を生成col1してcol2使用することはできますがrownum、これは非標準であり、元のクエリの出力を適切に並べ替える必要があります。

編集:

一時テーブルを使用できない場合は、サブクエリを使用できると思います。

select tmp1.col3, tmp2.col3, tmp3.col3 from
  (select col1, col3 from (ORIGINAL_QUERY) where col2 = 1) as tmp1,
  (select col1, col3 from (ORIGINAL_QUERY) where col2 = 2) as tmp2,
  (select col1, col3 from (ORIGINAL_QUERY) where col2 = 3) as tmp3
where tmp1.col1 = tmp2.col1 and tmp1.col1 = tmp3.col1;

オプティマイザが賢いことを願っています。

于 2012-12-19T22:06:45.477 に答える