1
0

query97.sql 1.0 KB

12345678910111213141516171819202122232425
  1. -- start query 1 in stream 0 using template query97.tpl and seed 1819994127
  2. with ssci as (
  3. select ss_customer_sk customer_sk
  4. ,ss_item_sk item_sk
  5. from store_sales,date_dim
  6. where ss_sold_date_sk = d_date_sk
  7. and d_month_seq between 1190 and 1190 + 11
  8. group by ss_customer_sk
  9. ,ss_item_sk),
  10. csci as(
  11. select cs_bill_customer_sk customer_sk
  12. ,cs_item_sk item_sk
  13. from catalog_sales,date_dim
  14. where cs_sold_date_sk = d_date_sk
  15. and d_month_seq between 1190 and 1190 + 11
  16. group by cs_bill_customer_sk
  17. ,cs_item_sk)
  18. select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
  19. ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
  20. ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
  21. from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
  22. and ssci.item_sk = csci.item_sk)
  23. limit 100;
  24. -- end query 1 in stream 0 using template query97.tpl