Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.80 KB | None | 0 0
  1. --      product series that have at least a product with analog synthesis and one with digital synthesis
  2.  
  3. SELECT  ProductSeries.serial_number
  4. FROM ProductSeries
  5. WHERE ProductSeries.series_id= ANY(SELECT ProductModel.part_of FROM ProductModel WHERE ProductModel.type_of_synthesis='Analog')
  6.     AND ProductSeries.series_id= ANY(SELECT ProductModel.part_of FROM ProductModel WHERE ProductModel.type_of_synthesis='Digital')
  7.  
  8. --  rewrite
  9.  
  10. SELECT ProductSeries.serial_number
  11. FROM ProductSeries
  12.     inner join ProductModel on ProductModel.type_of_synthesis='Analog' and ProductModel.part_of=ProductSeries.series_id
  13.     inner join ProductModel pm on pm.type_of_synthesis='Digital' and pm.part_of=ProductSeries.series_id
  14. GROUP BY ProductSeries.serial_number
  15. HAVING COUNT(ProductModel.model_id) > 0 and COUNT(pm.model_id) > 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement