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.
| Author |
Topic |
|
paulpol87
Starting Member
7 Posts |
Posted - 2012-01-28 : 13:02:38
|
| i'm new to sql and doing my best to understand it.. things got a little bit complicated so i need some help.i have the following:Short database description "Computer firm":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)The table "Product" includes information about the maker, model number, and type ('PC', 'Laptop', or 'Printer'). It is assumed that model numbers in the Product table are unique for all the makers and product types. Each PC uniquely specifying by a code in the table "PC" is characterized by model (foreign key referencing to Product table), speed (of the processor in MHz), total amount of RAM - ram (in Mb), hard disk drive capacity - hd (in Gb), CD ROM speed - cd (for example, '4x'), and the price. The table "Laptop" is similar to that one of PCs except for the CD ROM speed, which is replaced by the screen size - screen (in inches). For each printer in the table "Printer" it is told whether the printer is color or not (color attribute is 'y' for color printers; otherwise it is 'n'), printer type (laser, jet, or matrix), and the price.Task: Find the makers of the PCs that have speed not less than 450MHz. Result set: Maker.i have tried the following command:select distinct maker from product join pc on product.model=pc.model where pc.speed>450so i got the following answer:Incorrect.Your query produced correct result set on main database, but it failed test on second, checking database.* Wrong number of records (less by 2)there is also a tip of what commands i should use and it's: Explicit join operations Simple SELECT statementwhat is the correct command?? thanks for your time/help |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-01-28 : 13:20:57
|
| Homework?Your question is for "not less than 450". Your query is for greater than 450. They're not logically the same.--Gail ShawSQL Server MVP |
 |
|
|
paulpol87
Starting Member
7 Posts |
Posted - 2012-01-28 : 13:23:56
|
| so what is the command i should enter? thanks |
 |
|
|
paulpol87
Starting Member
7 Posts |
Posted - 2012-01-28 : 13:25:04
|
| sort of homework :))i'm learning while i'm trying to do some exercises online |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-01-28 : 14:25:00
|
| I'm not going to do your work for you. I don't need the practice and you don't learn to think through problemsThink about that where clause. The problem asks for all cases where the speed is not less than 450. Your query is filtering for those that are greater than 450. They are not logically equivalent. Think about what the two mean.If I have a list of values:100250450500750Which of those are NOT less than 450? Which are greater than 450? Where's the difference between those two logical comparisons?--Gail ShawSQL Server MVP |
 |
|
|
paulpol87
Starting Member
7 Posts |
Posted - 2012-01-28 : 20:44:19
|
| i can't believe it.... just an =.... i've tried to find the mistake for a few hours :pthanks a lot for your answer :) |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-01-29 : 07:19:53
|
| Yup. Exactly.--Gail ShawSQL Server MVP |
 |
|
|
|
|
|
|
|