While I was working on mission 179-7, I typed the code for the problem like the below and got the right result. However, before I moved on to the next page I checked the answer sheet and found that their code is different from mine. Whereas I filtered the row after joining the table, in the answer, they did the filtering on the original table first and then joined the table to the other one.
SELECT c.name capital_city, f.name country, c.population FROM facts f INNER JOIN ( SELECT * FROM cities WHERE capital = 1 ) c ON c.facts_id = f.id WHERE c.population > 10000000 ORDER BY c.population DESC;
SELECT c.name capital_city, f.name country, c.population population FROM facts f INNER JOIN ( SELECT * FROM cities WHERE capital = 1 AND population > 10000000 ) c ON c.facts_id = f.id ORDER BY 3 DESC;
I can understand how the two codes are following different order when they are executed yet showing the same result but want to know if it’s just a matter of writing style that my code is different from the provided answer or there’s something more at deeper level.