Can someone help solve this? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Can someone help solve this?

Consider the following tables CREATE TABLE CUSTOMER_SUMMARY
(
CUSTOMER_ID int NOT NULL PRIMARY KEY CLUSTERED,
TOTAL_ORDERS int NOT NULL,
PAID_ORDERS int NOT NULL,
FIRST_PAYMENT_DATE datetime NULL,
…..
) CREATE TABLE ORDERS
(
ORDER_ID int NOT NULL PRIMARY KEY CLUSTERED,
CUSTOMER_ID int NOT NULL,
ORDER_PLACED_DATE datetime NOT NULL,
…..
) Both tables contain data from 01/01/2002 to present. Paid Buyer … Any customer with at least one paid order
Paid Buyer Chronology … Any paid buyer is considered unpaid buyer prior to the First Payment Date and paid buyer on and after the First Payment Date Write code that will populate the following table months for each month between 01/01/2002 and the current month with counts of paid buyers (i.e. paid buyer as of the end of the given month) with a purchase (placed order) in last 6 months period (ending with the end of the given month). CREATE TABLE PAID_BUYER_STATS_BY_MONTH
(
[YEAR] int NOT NULL,
[MONTH] int NOT NULL,
PB_PURCHASE_LST6MO int NOT NULL
)

DDL we have already. Can you also give some sample data and what the required output should look like, so that it is getting more clear (at least to me…)? —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)

]]>