SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL exercise problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rob887
Starting Member

2 Posts

Posted - 05/11/2012 :  04:32:45  Show Profile  Reply with Quote
Was hoping someone may be able to help me, the question I am trying is from sql-ex.ru

------------------

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)

Exercise: 25
Find the printer makers which also produce PCs with the lowest RAM and the highest-speed processor among PCs with the lowest RAM. Result set: maker.


----------------------

I've tried attempting this from several different angles and have had different problems with each attempt, however in each I've been able to see why it wont work, except this one:


SELECT DISTINCT maker FROM product INNER JOIN
PC ON PC.model = product.model INNER JOIN
(SELECT p.ram, MAX(p.Speed) as speed FROM pc p
    GROUP BY p.ram
    HAVING p.ram = 
        (SELECT MIN(ram) FROM pc)
   )T ON T.ram = pc.ram AND T.speed = pc.speed


It says on a testing table that it gave an extra record by 1.

As I see it the subquery should pull out [min ram][max speed] fine then by joining this into the Product table joined with the PC table only the results which satisfy the subquery should be returned?

Edited by - rob887 on 05/11/2012 04:45:41

vijays3
Constraint Violating Yak Guru

India
343 Posts

Posted - 05/11/2012 :  06:01:11  Show Profile  Reply with Quote
can you provide sample data for all tables?
Go to Top of Page

rob887
Starting Member

2 Posts

Posted - 05/11/2012 :  06:11:35  Show Profile  Reply with Quote
you know what... I went to grab you the sample data and for the tables I've used and noticed what the problem is. I haven't included the fact that they only want printer manufacturers :(. Been looking at this for hours and missed the obvious!!!
Go to Top of Page

gmb.dorr
Starting Member

USA
4 Posts

Posted - 01/22/2013 :  17:33:35  Show Profile  Reply with Quote
I'm stuck in this :(
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000