Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 whats wrong with this!?

Author  Topic 

Amber99
Starting Member

11 Posts

Posted - 2009-04-05 : 14:22:55
Hey!
My answer is correct but it says:

Your query produced correct result set on main database, but it failed test on second, checking database.
* Wrong number of records (more by 2)

Question:
Exercise: 9
Find the makers of the PCs that have speed not less than 450MHz. Result set: Maker.


My Query:
SELECT DISTINCT Product.maker FROM Product, PC where PC.speed >= 450 AND Product.type = 'PC' group by Product.maker

whats the deal? why am i wrong now? does anyone know?

Thanks

Amber

The database scheme consists of four tables:
Product(maker, model, type)
PC(code, model, speed, ram, hd, cd, price)
Laptop(code, model, speed, ram, hd, screen, price)
Printer(code, model, color, type, price)

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-04-06 : 02:46:10
is there any relationship between Pc and Product? there is no joint in your query.
is the modelsame for product and PC?

if so, your query should be
SELECT DISTINCT Product.maker FROM Product, PC where PC.speed >= 450 AND Product.type = 'PC'
AND PC.Model = Product.Model
group by Product.maker

check out my blog at http://www.aquariumlore.blogspot.com
Go to Top of Page

Amber99
Starting Member

11 Posts

Posted - 2009-04-06 : 20:30:44
works perfect!! Thanks!
Go to Top of Page

besanu
Starting Member

1 Post

Posted - 2010-12-06 : 11:42:11
There is an easier code :

SELECT DISTINCT maker
FROM product INNER JOIN
pc ON pc.model = product.model
WHERE pc.speed >= 450

simple as 1,2,3 . . .
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-12-06 : 13:17:41
Please note: Almost 2 year old (homework) thread.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -