Wednesday, March 7, 2012

Quick DMX question

Is there anyway to predict what a customer is likely to buy based on their purchase history?

What I would like to do is something simliar to using a natural prediction join with multiple union selects, but with data supplied from my purchases table.

So I need something like this:

Code Snippet

Openquery([ds], 'SELECT DISTINCT [PurchasedProductID] FROM [Table] WHERE [CompanyName] = 'a')

To work like how this works:

Code Snippet

(SELECT (SELECT '1234' AS [ProductID] UNION SELECT '12345' AS [ProductID]) AS [Table])

Thanks!

You can try this:
... <Model> NATURAL PREDICTION JOIN
SHAPE {
OPENQUERY([DS], 'SELECT ''A'' AS CompanyName')
} APPEND
( {
Openquery([ds], 'SELECT DISTINCT [CompanyName], [PurchasedProductID] FROM [Table] WHERE [CompanyName] = ''a'' ')
} RELATE [CompanyName] TO [CompanyName]
) AS [Table]
AS T

Note the "fake" top level row (the first query) which just serves as foreign key to group the entries in the nested (APPEND) statement|||wow! It works! Thanks so much!

No comments:

Post a Comment