query91.sql 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. select
  2. cc_call_center_id Call_Center,
  3. cc_name Call_Center_Name,
  4. cc_manager Manager,
  5. sum(cr_net_loss) Returns_Loss
  6. from
  7. call_center,
  8. catalog_returns,
  9. date_dim,
  10. customer,
  11. customer_address,
  12. customer_demographics,
  13. household_demographics
  14. where
  15. catalog_returns.cr_call_center_sk = call_center.cc_call_center_sk
  16. and catalog_returns.cr_returned_date_sk = date_dim.d_date_sk
  17. and catalog_returns.cr_returning_customer_sk= customer.c_customer_sk
  18. and customer_demographics.cd_demo_sk = customer.c_current_cdemo_sk
  19. and household_demographics.hd_demo_sk = customer.c_current_hdemo_sk
  20. and customer_address.ca_address_sk = customer.c_current_addr_sk
  21. and d_year = 1999
  22. and d_moy = 11
  23. and cr_returned_date between '1999-11-01' and '1999-11-31'
  24. and ( (cd_marital_status = 'M' and cd_education_status = 'Unknown')
  25. or(cd_marital_status = 'W' and cd_education_status = 'Advanced Degree'))
  26. and hd_buy_potential like '0-500%'
  27. and ca_gmt_offset = -7
  28. group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
  29. order by Returns_Loss desc;