Skip to content

Instantly share code, notes, and snippets.

@yssymmt
Created April 17, 2022 14:48
Show Gist options
  • Save yssymmt/da478cd945d3b382637897cdbba3a957 to your computer and use it in GitHub Desktop.
Save yssymmt/da478cd945d3b382637897cdbba3a957 to your computer and use it in GitHub Desktop.
with src as (
select
レシート番号,
商品
from データベース名.テーブル名
group by 1,2
)
/*組み合わせデータの作り方だけ、本来は指標も作成*/
select
a1.商品 as 商品1,
a2.商品 as 商品2
from src a1 inner join src a2
on a1.レシート番号=a2.レシート番号
and a1.商品番号<>a2.商品番号 and a1.商品番号<a2.商品番号
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment