ソースコード
with t1 as 
(
select 
  a.item_code as ITEM_A 
  ,b.item_code as ITEM_B 
  ,count(distinct a.session_id) as session_cnt 
  ,count(distinct b.session_id) as b_session_cnt
from purchase_history a 
inner join purchase_history b 
  on a.session_id = b.session_id
  and a.item_code <> b.item_code 
group by 1,2
)
, t2 as 
(
  select count(distinct session_id) as total_session_cnt 
  from purchase_history
)
select
  ITEM_A
  ,ITEM_B
  ,round(cast(session_cnt as real) / (select total_session_cnt from t2) * 100, 6) as SUPPORT
  ,round(cast(session_cnt as real) / (select count(distinct session_id) from purchase_history where item_code = ITEM_A) * 100, 6) as CONFIDENCE
  ,round((cast(session_cnt as real) / (select count(distinct session_id) from purchase_history where item_code = ITEM_A) * (select total_session_cnt from t2)) / cast(b_session_cnt as real), 6) as LIFT
from t1 
order by LIFT desc, SUPPORT desc, CONFIDENCE desc, ITEM_A desc
;
提出情報
提出日時2024/02/19 10:20:34
コンテスト第11回 SQLコンテスト
問題アソシエーション分析
受験者hattsuriboy
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量99 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
96 MB
データパターン2
WA
99 MB
データパターン3
WA
97 MB