XD-DENG / SQL-exercise

Practice with "Real" SQL Problems
1.34k stars 570 forks source link

maybe there is something with -- 1.16 #11

Closed Juary88 closed 6 years ago

Juary88 commented 6 years ago

it should be : select p.name,m.name,p.price from products p join manufacturers m on p.manufacturer = m.code where p.price in ( select min(a.price) from Manufacturers b join Products a on a.Manufacturer = b.code group by b.name); Your answer always showes the wrong product name to match the price.

XD-DENG commented 6 years ago

Hi @Juary88

The output is

(product) Name        MAX(Price)  (manufacturer)Name
DVD drive   180         Creative Labs
Hard drive  240         Fujitsu
Printer     270         Hewlett-Packa
ZIP drive   150         Iomega
Monitor     240         Sony
Memory      120         Winchester

And it looks correct to me. May you clarify a bit more about your question?

Thanks.

Juary88 commented 6 years ago

Actually the product name does not match the price if you change max function to the min.

XD-DENG commented 6 years ago

But the question itself is "-- 1.16 Select the name of each manufacturer along with the name and price of its most expensive product."?

Juary88 commented 6 years ago

Because you just meet the right answer,if you chang the sequence of the name,your answer is wrong

XD-DENG commented 6 years ago

I guess what you wanted to say is 瞎猫撞上死耗子? LOL

May you provide a minimal reproducible sample? Not sure what you meant by "change the sequence of the name".

Thanks.

Juary88 commented 6 years ago

For instance,if I change the price of Memory 120 to 4,your answer is: 1522801382 1 The product name does not change.

but the right answer is: 1522801477 1

and two products have the same price,you should both show them.

XD-DENG commented 6 years ago

所以你想指出的问题是应该把“Creative Labs”下属两个同样价钱(同时也是最贵)的产品同时列出来,而不是你最开始说的“Your answer always showes the wrong product name to match the price.”?如果这样的话我也不太理解为什么要把Memory的价钱改到4才能复现这个问题?

会做相应的修改。谢谢。

XD-DENG commented 6 years ago

Addressed in e05d781341c3791951ddf54c94ee32ca11cf5896