ソースコード
with t0 as (
select item_code as i, count(distinct(member_code)) as c
from PURCHASE_HISTORY
group by 1
order by 1
),
t1 as (
select p0.item_code as i0,
p1.item_code as i1,
count(distinct(p0.member_code)) as c
from PURCHASE_HISTORY as p0
inner join PURCHASE_HISTORY as p1
on p0.item_code!=p1.item_code and
p0.member_code=p1.member_code
group by 1,2
order by 1,2
)
select i0 as 'ITEM_A',
i1 as 'ITEM_B',
round(t1.c*100.0/(select count(distinct(MEMBER_CODE)) from PURCHASE_HISTORY),5) as 'SUPPORT',
round(t1.c*100.0/x.c,5) as 'CONFIDENCE',
round(t1.c*1.0/x.c/y.c*(select count(distinct(MEMBER_CODE)) from PURCHASE_HISTORY),5) as 'LIFT'
from t1
inner join t0 as x
on t1.i0=x.i
inner join t0 as y
on t1.i1=y.i
order by 5 desc,3 desc,4 desc,1 desc
提出情報
提出日時2024/02/19 11:14:42
コンテスト第11回 SQLコンテスト
問題アソシエーション分析
受験者tabr
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量102 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
93 MB
データパターン2
AC
93 MB
データパターン3
AC
102 MB