query94.sql 955 B

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