Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!

SQL for adding data linked to the filtering dimension

Avatar

Employee

This is from the Recipient RFM example where all Recipients are pulled in the initial Query and then we add data linked to the filtering dimension to compute recency, frequency and monetary.

INSERT INTO wkf505995918_2_2 (dPurchaseHistoryMonetary,tsPurchaseHistoryRecency,iPurchaseHistoryFrequency,iPurchaseHistoryKeysPKey0) SELECT DISTINCT   Sum(P0.dAmount), Max(P0.tsDate), Count(P0.iPurchaseHistoryId), P0.iRecipientId FROM NeoPurchaseHistory P0 JOIN wkf505995918_2_1 W ON (W.iLinksKey1_0=P0.iRecipientId)  WHERE (P0.tsDate >= add_months(CAST((GetDate()) AT TIME ZONE 'America/New_York' AS date), -(18))) AND ((P0.iPurchaseHistoryId > 0 OR P0.iPurchaseHistoryId < 0)) GROUP BY P0.iRecipientId

Note the JOIN between the linked NeoPurchaseHistory table and the wkf505995918_2_1 table populated by the initial query. The JOIN is ON the Recipient ID.

0 Replies