ソースコード
with 
sub1 as (
    select
        ph.member_code
        , mc.member_cnt
        , ph.item_code
        , count(1) over (partition by ph.item_code) as item_cnt
    from PURCHASE_HISTORY ph
    cross join (select count(distinct member_code) as member_cnt from PURCHASE_HISTORY) as mc
),
sub2 as (
    select 
        s1.item_code as item_a
        , s2.item_code as item_b
        , s1.item_cnt as a_cnt
        , s2.item_cnt as b_cnt
        , count(1) as ab_cnt
        , s1.member_cnt as m_cnt
    from sub1 s1
    inner join sub1 s2 on s1.member_code=s2.member_code
    where s1.item_code<>s2.item_code
    group by 1,2,3,4,6
)
select 
    item_a ITEM_A
    , item_b ITEM_B
    , round(100*ab_cnt / m_cnt, 5) as SUPPORT
    , round(100*ab_cnt / a_cnt, 5) as CONFIDENCE
    , round((1.0*ab_cnt / a_cnt) / (1.0*b_cnt / m_cnt), 5) as LIFT
from sub2
order by 
5 desc, 3 desc, 4 desc, 1 desc;
提出情報
提出日時2024/05/08 14:43:22
コンテスト第11回 SQLコンテスト
問題アソシエーション分析
受験者sjty9561
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
85 MB
データパターン3
WA
85 MB