このクエリは、2つのテーブルから次の結果を返します。カウントは、IDに関連付けられている製品の数です。
select pog.DBKey
,Count(pos.DBParentProductKey)
as Total
from ix_spc_planogram as pog with (nolock)
, ix_spc_position as pos with (nolock)
where pog.dbkey = pos.dbparentplanogramkey
and pog.Value4 = 358
group by pog.dbkey
DBKEY Total
2134 20
2132 22
2133 20
次に、この情報を使用して、2134が2133と同じDBParentProductKeysを持っているかどうかを判断する必要があります。次のようにDbKEysのようなものをすべてグループ化する必要があります。
DBKEY Assortment
2134 1 1+1 because it has the same ParentProductKeys
2133 1
2132 2
この問題を解決する方法についてのアイデアは非常に役立ちます。