Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jun 18th, 2018 58 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. with customer_total_return as
  2.  (select cr_returning_customer_sk as ctr_customer_sk
  3.         ,ca_state as ctr_state,
  4.     sum(cr_return_amt_inc_tax) as ctr_total_return
  5.  from catalog_returns
  6.      ,date_dim
  7.      ,customer_address
  8.  where cr_returned_date_sk = d_date_sk
  9.    and d_year =1998
  10.    and cr_returning_addr_sk = ca_address_sk
  11.  group by cr_returning_customer_sk
  12.          ,ca_state )
  13.   select  c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
  14.                    ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
  15.                   ,ca_location_type,ctr_total_return
  16.  from customer_total_return ctr1
  17.      ,customer_address
  18.      ,customer
  19.  where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
  20.               from customer_total_return ctr2
  21.                       where ctr1.ctr_state = ctr2.ctr_state)
  22.        and ca_address_sk = c_current_addr_sk
  23.        and ca_state = 'IL'
  24.        and ctr1.ctr_customer_sk = c_customer_sk
  25.  order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name
  26.                    ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset
  27.                   ,ca_location_type,ctr_total_return
  28.  limit 100;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top