query90.sql 968 B

12345678910111213141516171819202122
  1. select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
  2. from ( select count(*) amc
  3. from web_sales, household_demographics , time_dim, web_page
  4. where ws_sold_time_sk = time_dim.t_time_sk
  5. and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
  6. and ws_web_page_sk = web_page.wp_web_page_sk
  7. and time_dim.t_hour between 6 and 6+1
  8. and household_demographics.hd_dep_count = 8
  9. and web_page.wp_char_count between 5000 and 5200) at,
  10. ( select count(*) pmc
  11. from web_sales, household_demographics , time_dim, web_page
  12. where ws_sold_time_sk = time_dim.t_time_sk
  13. and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
  14. and ws_web_page_sk = web_page.wp_web_page_sk
  15. and time_dim.t_hour between 14 and 14+1
  16. and household_demographics.hd_dep_count = 8
  17. and web_page.wp_char_count between 5000 and 5200) pt
  18. order by am_pm_ratio
  19. limit 100;