Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- product series that have at least a product with analog synthesis and one with digital synthesis
- SELECT ProductSeries.serial_number
- FROM ProductSeries
- WHERE ProductSeries.series_id= ANY(SELECT ProductModel.part_of FROM ProductModel WHERE ProductModel.type_of_synthesis='Analog')
- AND ProductSeries.series_id= ANY(SELECT ProductModel.part_of FROM ProductModel WHERE ProductModel.type_of_synthesis='Digital')
- -- rewrite
- SELECT ProductSeries.serial_number
- FROM ProductSeries
- inner join ProductModel on ProductModel.type_of_synthesis='Analog' and ProductModel.part_of=ProductSeries.series_id
- inner join ProductModel pm on pm.type_of_synthesis='Digital' and pm.part_of=ProductSeries.series_id
- GROUP BY ProductSeries.serial_number
- HAVING COUNT(ProductModel.model_id) > 0 and COUNT(pm.model_id) > 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement