q79.sql 1.1 KB

1234567891011121314151617181920212223242526
  1. --!syntax_pg
  2. --TPC-DS Q79
  3. -- start query 1 in stream 0 using template ../query_templates/query79.tpl
  4. select
  5. c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
  6. from
  7. (select ss_ticket_number
  8. ,ss_customer_sk
  9. ,store.s_city
  10. ,sum(ss_coupon_amt) amt
  11. ,sum(ss_net_profit) profit
  12. from plato.store_sales,plato.date_dim,plato.store,plato.household_demographics
  13. where store_sales.ss_sold_date_sk = date_dim.d_date_sk
  14. and store_sales.ss_store_sk = store.s_store_sk
  15. and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
  16. and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
  17. and date_dim.d_dow = 1
  18. and date_dim.d_year in (1998,1998+1,1998+2)
  19. and store.s_number_employees between 200 and 295
  20. group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,plato.customer
  21. where ss_customer_sk = c_customer_sk
  22. order by c_last_name,c_first_name,substr(s_city,1,30), profit
  23. limit 100;
  24. -- end query 1 in stream 0 using template ../query_templates/query79.tpl