q68.sql 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --!syntax_pg
  2. --TPC-DS Q68
  3. -- start query 1 in stream 0 using template ../query_templates/query68.tpl
  4. select c_last_name
  5. ,c_first_name
  6. ,ca_city
  7. ,bought_city
  8. ,ss_ticket_number
  9. ,extended_price
  10. ,extended_tax
  11. ,list_price
  12. from (select ss_ticket_number
  13. ,ss_customer_sk
  14. ,ca_city bought_city
  15. ,sum(ss_ext_sales_price) extended_price
  16. ,sum(ss_ext_list_price) list_price
  17. ,sum(ss_ext_tax) extended_tax
  18. from plato.store_sales
  19. ,plato.date_dim
  20. ,plato.store
  21. ,plato.household_demographics
  22. ,plato.customer_address
  23. where store_sales.ss_sold_date_sk = date_dim.d_date_sk
  24. and store_sales.ss_store_sk = store.s_store_sk
  25. and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
  26. and store_sales.ss_addr_sk = customer_address.ca_address_sk
  27. and date_dim.d_dom between 1 and 2
  28. and (household_demographics.hd_dep_count = 5 or
  29. household_demographics.hd_vehicle_count= 3)
  30. and date_dim.d_year in (1999,1999+1,1999+2)
  31. and store.s_city in ('Midway','Fairview')
  32. group by ss_ticket_number
  33. ,ss_customer_sk
  34. ,ss_addr_sk,ca_city) dn
  35. ,plato.customer
  36. ,plato.customer_address current_addr
  37. where ss_customer_sk = c_customer_sk
  38. and customer.c_current_addr_sk = current_addr.ca_address_sk
  39. and current_addr.ca_city <> bought_city
  40. order by c_last_name
  41. ,ss_ticket_number
  42. limit 100;
  43. -- end query 1 in stream 0 using template ../query_templates/query68.tpl