简体   繁体   中英

Sql-ex.ru - Exercise 23

Currently stuck on the question above, the code I'm using is currently generating the right answer but I'm getting the "Your query returned the correct dataset on the first (available) database, but it returned incorrect dataset on the second checking database." message. Below is what I'm using:

SELECT DISTINCT a.maker
FROM (
SELECT maker, product.model
FROM product
JOIN pc
ON product.model=pc.model
WHERE pc.speed>=750
) AS a
LEFT JOIN (
SELECT maker, product.model
FROM product
JOIN laptop
ON product.model=laptop.model
WHERE laptop.speed>=750
) AS b
ON a.model=b.model

The question is: Get the makers producing both PCs having a speed of 750 MHz or higher and laptops with a speed of 750 MHz or higher. I'm joining two tables which contain the products I'm after, and outputting it as the maker. How come it's telling me it's incorrect?

This works for me:

SELECT Product.maker
FROM Product
INNER JOIN PC
ON Product.model = PC.model
WHERE PC.speed>=750
INTERSECT
SELECT Product.maker
FROM Product
INNER JOIN Laptop
ON Product.model = Laptop.model
WHERE Laptop.speed>=750

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM