我面临着返回前N对产品的问题,即客户购买的共同点。让说,我有以下查询:获得前N对产品,客户通常购买
SELECT c.CustomerKey, ProductAlternateKey
FROM
[AdventureWorksDW2008R2].[dbo].[FactInternetSales] FIS JOIN
dbo.DimCustomer C ON C.CustomerKey = FIS.CustomerKey JOIN
dbo.DimProduct P ON P.ProductKey = FIS.ProductKey
GROUP BY
C.CustomerKey, P.ProductAlternateKey
,并返回结果如下:
CustomerKey | ProductAlternateKey|
-------------+-----------+
0001 | A |
0001 | B |
0002 | A |
0002 | B |
0002 | C |
0003 | B |
0003 | C |
0004 | A |
0004 | B |
0005 | A |
0005 | C |
从这个查询我想找到顶部2对客户买,所以在我的例子产品 - >(A,B)出现3次,(B,C)→出现2次
,并将答案在这种情况下怎么办? – 2013-03-25 16:23:39
我在我的案例中添加了答案来编辑我的问题。 – Konza 2013-03-26 08:36:01