0

次のような 2 つのテーブルを持つ Apache Kylin (1.5.3) でキューブを作成しました。

Facttable   || Dimensiontable
id_a | id_b ||  id  | pos
------------------------------
01   | 011  || 011  | 1
01   | 011  || 012  | 1
01   | 011  || 013  | 0
01   | 012  || 021  | 1
01   | 013  || 022  | 0
02   | 021  || 023  | 0
02   | 022  || 031  | 1
02   | 023  || 032  | 0
03   | 031  || 033  | 0
03   | 032  || 034  | 1
03   | 033  || 035  | 1
03   | 034  ||
03   | 034  ||
03   | 034  ||
03   | 035  ||
03   | 035  ||

テーブルは、facttable.id_b = dimensiontable.id で結合されています。「キューブ デザイナー - 詳細設定」で、「includes」に id_a、id_b、および pos を含む 1 つの集計グループを作成しました。

ここで、「pos = 1」が複数回関連しているすべての id_a を知りたいと思います。

したがって、上記の表の場合:

id_a | count
------------ 
01   | 2
03   | 3

「洞察」タブで、クエリを試しました

select ft.id_a, count(ft.id_a)
from(
    select id_a, id_b
    from facttable
    group by id_b, id_a
) as ft inner join (
    select id
    from dimensiontable
    where pos = 1
) as dt on (ft.id_a = dt.id)
group by ft.id_a
having (count(ft.id_a) > 1);

しかし、それは戻ります

SQL "[query]" の実行中にエラーが発生しました: null

誰が問題が何であるか知っていますか?「モデルの作成」または「キューブの作成」でいくつかの設定を変更する必要がありますか?

どんな助けでも大歓迎です!

4

1 に答える 1

1

あなたの要件は私には以下のように聞こえます。

select
    id_a, count(distinct id_b)
from
    facttable
    inner join dimensiontable
    on facttable.id_b = dimensiontable.id
where
    pos = 1
group by
    id_a
having
    count(distinct id_b) > 1
于 2016-08-21T05:04:37.093 に答える