Hi,
dank deiner Hilfe habe ich nun folgendes Statement gebastelt:
SELECTDISTINCT c.customerid,
c.reg_dayid AS Reg_day,
( CASE
WHEN cpn.jackpot_alert > 0 and cml.standard_newsletter > 0 THEN 'C'
WHEN cpn.jackpot_alert = 0 and cml.standard_newsletter > 0 THEN 'B'
WHEN cml.standard_newsletter = 0 and cpn.jackpot_alert > 0 THEN 'A'
ELSE''END ) AS Flag
FROM dwh.cust_mailing_list cml,
dwh.sales s,
dwh.cust_prod_notify cpn,
dwh.customer c
WHERE cml.customerid = s.customerid
AND cml.customerid = cpn.customerid
AND cml.customerid = c.customerid
AND cpn.productid = '1'
AND s.productid = '1'
AND s.siteid = '2'
AND s.paid = '1'
AND s.cancelled = '0'
AND s.purchasedayid >= '20121201'
AND c.reg_dayid >= '20121201'
ORDERBY 1;
Das Ergebnis ist eine Tabelle mit allen CustomerId's die jeweils in Gruppen A, B oder C aufgeteilt wurden. Wie kann ich diese denn nun zählen? Ich möchte also wissen wieviele Customer in Gruppe A, b sowie C sind.
Vielen Dank