Back to home page

OSCL-LXR

 
 

    


0001 WITH customer_total_return AS
0002 (SELECT
0003     wr_returning_customer_sk AS ctr_customer_sk,
0004     ca_state AS ctr_state,
0005     sum(wr_return_amt) AS ctr_total_return
0006   FROM web_returns, date_dim, customer_address
0007   WHERE wr_returned_date_sk = d_date_sk
0008     AND d_year = 2002
0009     AND wr_returning_addr_sk = ca_address_sk
0010   GROUP BY wr_returning_customer_sk, ca_state)
0011 SELECT
0012   c_customer_id,
0013   c_salutation,
0014   c_first_name,
0015   c_last_name,
0016   c_preferred_cust_flag,
0017   c_birth_day,
0018   c_birth_month,
0019   c_birth_year,
0020   c_birth_country,
0021   c_login,
0022   c_email_address,
0023   c_last_review_date,
0024   ctr_total_return
0025 FROM customer_total_return ctr1, customer_address, customer
0026 WHERE ctr1.ctr_total_return > (SELECT avg(ctr_total_return) * 1.2
0027 FROM customer_total_return ctr2
0028 WHERE ctr1.ctr_state = ctr2.ctr_state)
0029   AND ca_address_sk = c_current_addr_sk
0030   AND ca_state = 'GA'
0031   AND ctr1.ctr_customer_sk = c_customer_sk
0032 ORDER BY c_customer_id, c_salutation, c_first_name, c_last_name, c_preferred_cust_flag
0033   , c_birth_day, c_birth_month, c_birth_year, c_birth_country, c_login, c_email_address
0034   , c_last_review_date, ctr_total_return
0035 LIMIT 100