q94.sql 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. --!syntax_pg
  2. --TPC-DS Q94
  3. -- start query 1 in stream 0 using template ../query_templates/query94.tpl
  4. select
  5. count(distinct ws_order_number) as "order count"
  6. ,sum(ws_ext_ship_cost) as "total shipping cost"
  7. ,sum(ws_net_profit) as "total net profit"
  8. from
  9. plato.web_sales ws1
  10. ,plato.date_dim
  11. ,plato.customer_address
  12. ,plato.web_site
  13. where
  14. d_date between '1999-5-01'::date and
  15. (cast('1999-5-01' as date) + interval '60' day)::date
  16. and ws1.ws_ship_date_sk = d_date_sk
  17. and ws1.ws_ship_addr_sk = ca_address_sk
  18. and ca_state = 'TX'
  19. and ws1.ws_web_site_sk = web_site_sk
  20. and web_company_name = 'pri'
  21. and exists (select *
  22. from plato.web_sales ws2
  23. where ws1.ws_order_number = ws2.ws_order_number
  24. and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
  25. and not exists(select *
  26. from plato.web_returns wr1
  27. where ws1.ws_order_number = wr1.wr_order_number)
  28. order by count(distinct ws_order_number)
  29. limit 100;
  30. -- end query 1 in stream 0 using template ../query_templates/query94.tpl