query41.sql 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. select distinct(i_product_name) from item i1
  2. where i_manufact_id between 742 and 742+40
  3. and (select count(*) as item_cnt
  4. from item
  5. where (i_manufact = i1.i_manufact and
  6. ((i_category = 'Women' and
  7. (i_color = 'orchid' or i_color = 'papaya') and
  8. (i_units = 'Pound' or i_units = 'Lb') and
  9. (i_size = 'petite' or i_size = 'medium')
  10. ) or
  11. (i_category = 'Women' and
  12. (i_color = 'burlywood' or i_color = 'navy') and
  13. (i_units = 'Bundle' or i_units = 'Each') and
  14. (i_size = 'N/A' or i_size = 'extra large')
  15. ) or
  16. (i_category = 'Men' and
  17. (i_color = 'bisque' or i_color = 'azure') and
  18. (i_units = 'N/A' or i_units = 'Tsp') and
  19. (i_size = 'small' or i_size = 'large')
  20. ) or
  21. (i_category = 'Men' and
  22. (i_color = 'chocolate' or i_color = 'cornflower') and
  23. (i_units = 'Bunch' or i_units = 'Gross') and
  24. (i_size = 'petite' or i_size = 'medium')
  25. )))) > 0
  26. or (select count(*) as item_cnt
  27. from item
  28. where (i_manufact = i1.i_manufact and
  29. ((i_category = 'Women' and
  30. (i_color = 'salmon' or i_color = 'midnight') and
  31. (i_units = 'Oz' or i_units = 'Box') and
  32. (i_size = 'petite' or i_size = 'medium')
  33. ) or
  34. (i_category = 'Women' and
  35. (i_color = 'snow' or i_color = 'steel') and
  36. (i_units = 'Carton' or i_units = 'Tbl') and
  37. (i_size = 'N/A' or i_size = 'extra large')
  38. ) or
  39. (i_category = 'Men' and
  40. (i_color = 'purple' or i_color = 'gainsboro') and
  41. (i_units = 'Dram' or i_units = 'Unknown') and
  42. (i_size = 'small' or i_size = 'large')
  43. ) or
  44. (i_category = 'Men' and
  45. (i_color = 'metallic' or i_color = 'forest') and
  46. (i_units = 'Gram' or i_units = 'Ounce') and
  47. (i_size = 'petite' or i_size = 'medium')
  48. )))) > 0
  49. order by i_product_name limit 100;