You are viewing a single comment's thread. Return to all comments →
I am confused as to why we need this line:
where w1.power = w.power and p1.age = p.age
Could someone please explain it's function?
^WSS can anyone explain the need of the above statement?
I don't understand this part too, why we have to match two tables that are exactly the same?
You use this line to only get the rows that have the same Power and Age. From these rows that have the same Power and Age you are able to get the minimun coins needed for that group.
you can achieve this by using group by too but then it produces multiple rows. so can't we use 'in' instead of '=' after where to detect these multiple rows
You are grouping all the rows(in subtable) that matches particularly given power, age from base table, then you take minimum coins of the group. Now you repeat for next particular power, age.
I struggled with this too. And I didn't understand the other people's explinations. But, I worked it out my self finally! If you don't include this you'll get the minimum for all of the rows! But including it, gets the minimum for groups that match in both power and age. It does seem like there should be a more intuitive way of doing this, such as usinging group by.
Thank you for the explanation. I think the description of the question let us confused. It is not hard, but the confusion of the question description consumes time.